Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Inserting at a bookmark if text found

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger Marrs - 16 Dec 2005 21:07 GMT
I'm trying to search for various strings of text in a document and if a
string is found, then inserting a block of text that's triggered by that
string into a different place in the document.

I understand how to code for the searches, and how to set up the default
text that will be added using Dim as String variables.  What I'm having
trouble understanding is how to write the code that says "I've found the
string of text, now I'm going to insert the Variable1 string at Bookmark1"

Hopefully the way I've explained what I'm trying to accomplish makes sense.

Roger Marrs
Jay Freedman - 17 Dec 2005 01:14 GMT
>I'm trying to search for various strings of text in a document and if a
>string is found, then inserting a block of text that's triggered by that
[quoted text clipped - 8 lines]
>
>Roger Marrs

Hi Roger,

After you set up the Find object, do something like this:

  If .Execute Then
      ActiveDocument.Bookmarks("Bookmark1").Range.Text = Variable1
  End If

This simple version clobbers the bookmark as it inserts the text. If
you need to have the bookmark still present after the insert, see
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Roger Marrs - 04 Jan 2006 17:50 GMT
That worked great.  Thank you.

> >I'm trying to search for various strings of text in a document and if a
> >string is found, then inserting a block of text that's triggered by that
[quoted text clipped - 27 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.