Find text in Word - without affecting the Find dialog box

D

David Thielen

If this helps, our code is as follows (selOn is the present selection in the
Word document):

Range range = selOn.Range.Duplicate;
range.Start = rangeStart;
range.End = rangeEnd;
range.Find.ClearFormatting();
range.Find.Forward = forward;
range.Find.Text = text;
range.Find.Wrap = WdFindWrap.wdFindStop;

object missingValue = Type.Missing;

range.Find.Execute(ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue);



--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

This a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

Thank you for your patience. Word closes the find dialog when
Range.Find.Execute is run by design, and we feel sorry if this behavior of
Word does not fit your situation. Based on our discussion, we do not find a
workaround for your request currently. Looking at the nature of this issue,
it would require intensive researches which would be done quickly and
effectively with direct assistance from a Microsoft Support Professional
through Microsoft Product Support Services. You can contact Microsoft
Product Support directly to discuss additional support options you may have
available, by contacting us at 1-(800)936-5800 or by choosing one of the
options listed at
http://support.microsoft.com/common/international.aspx?rdpath=fh;en-us;cntac
tms.

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

For the first question: how to efficiently find a string in Word plain
text, please refer to the String searching algorithms introduced in page:
http://en.wikipedia.org/wiki/String_searching_algorithm. It describes
serveral commonly used algorithms. For this case, I think that the KMP
(Knuth-Morris-Pratt) algorithm will be fine according to its time
complexity: O(m+n), (Let m be the length of the pattern and let n be the
length of the searchable text.) For details about KMP, see:
http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm.

For the second question, Word does not expose any method to detect if a
built-in dialog is opened or not. Therefore, I think we need to use our own
search function for all the cases.

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hi;

Those search algorithms are great - thank you.

The main part of my question was how should I pull the text from Word. If it
is a 100 page document I don't want to read all the text at once since what I
am searching for may be in the 1st paragraph. Should I pull the text a
paragraph at a time or is there a more efficient way to get text in
reasonably sized chunks?

BTW - you guys are the best developer support team among all 18 companies we
work with.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

I think that searching the string paragraph by paragraph will be fine.

If we get the text in a fixed sized chunk, (for instance, we get the text
for every 10 characters: document.Range(1, 10) ... document.Range(11, 20)),
we may miss the match of word if the string is located accross the two
chunks.
BTW - you guys are the best developer support team among all
18 companies we work with.
Thank you, Dave. We, the newsgroup support team, will continue doing our
best for customers.

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hi Dave,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top