Jumping to certain 'position' in office document

R

raindance

Hi,

I'm busy writing a sort of tracebility application in C#. This application
should open certain types of documents and then move cursor or focus at a
certain position in a document (word and excel).

I have managed to open office documents and then search for certain text
using the Find method. This does not always work however since the text I'm
searching for might appear in the document multiple times. E.g. when I
search for FF1234 I want to focus on a specific instance of that word in the
document and I also don't want to focus on FF12345.

Is it possible to use some sort of tags or identifiers to mark all the
instances I want to be searched and then only search them and ignore all
other instances of the same search fields in the document?

Please help, I have searched everywhere in MSDN library for VS 2005 and
haven't found anything.

Thanks :)
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?cmFpbmRhbmNl?=,

Well, in Word you can bookmark the positions. Bookmarks are fairly volatile,
however. You don't mention whether/how users work with these documents...

In Word, Find/Replace has a .MatchWildcards property. When that's set to "true"
you can search a pattern (similar, but not identical, to a regex), including
the beginning and end of a word. For example:
I'm busy writing a sort of tracebility application in C#. This application
should open certain types of documents and then move cursor or focus at a
certain position in a document (word and excel).

I have managed to open office documents and then search for certain text
using the Find method. This does not always work however since the text I'm
searching for might appear in the document multiple times. E.g. when I
search for FF1234 I want to focus on a specific instance of that word in the
document and I also don't want to focus on FF12345.

Is it possible to use some sort of tags or identifiers to mark all the
instances I want to be searched and then only search them and ignore all
other instances of the same search fields in the document?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
R

raindance

Hi Cindy,

These documents are typically generated by document factories and not
usually altered by hand. So bookmarks works perfectly. With bookmarks I can
also highlight the whole relevant paragraph in the document instead of just
the search term, which is also something I was looking for. Thanks for hint
:)

I figured out in the meantime the Find.Execute method has a MatchWholeWord
property which also solved my problem of half matches.

Thanks again.
 

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