Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Bookmarks Disappear

Status
Not open for further replies.

jrobin5881

Technical User
Mar 10, 2004
228
US
This is somewhat baffling?? I created a word document in word 2003. At key points I inserted bookmarks where I want text to be inserted off of a userform that will appear when the document is opened.

For some reason they disappeared while testing? I'm pretty sure that I don't have a virus due to me being on the LAN at work and they are super tight and have the system pretty locked down. Or, is this a product of something that I'm doing or they way the system is designed.

I re-entered the bkmarks and some dropped out again.. I made sure I saved them and can see them in the bookmark list.
 
I want text to be inserted
How did you that ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ub test()

With ActiveDocument
.Bookmarks("bkDcoord").Range.Text = "Test Hello"
.Bookmarks("bkAcoord").Range.Text = "Test Hello"
.Bookmarks("bkOffice").Range.Text = "Test Hello"
.Bookmarks("bkDay").Range.Text = "Test Hello"
.Bookmarks("bkDate").Range.Text = "Test Hello"
.Bookmarks("bkF4").Range.Text = "Test Hello"
.Bookmarks("bkDel").Range.Text = "Test Hello"
.Bookmarks("bkVol").Range.Text = "JTest Hello"
.Bookmarks("bkSOP").Range.Text = "Test Hello"
.Bookmarks("bkDois").Range.Text = "Test Hello"
.Bookmarks("bkScore").Range.Text = "JTest Hello"
.Bookmarks("bkPlan").Range.Text = "Test Hello"
.Bookmarks("bkAccord2").Range.Text = "Test Hello"
End With


End Sub
 
To keep the whole bookmark range, try something like this:
With Application.Selection
.GoTo What:=wdGoToBookmark, Name:="bkDcoord"
.Collapse Direction:=wdCollapseEnd
ActiveDocument.Bookmarks("bkDcoord").Range.Text = "Test Hello"
.MoveEnd Unit:=wdCharacter, Count:=Len("Test Hello")
ActiveDocument.Bookmarks.Add Name:="bkDcoord", Range:=Application.Selection.Range
.Collapse Direction:=wdCollapseEnd
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
See the thread "Changing text in word bookmark" - thread707-1266008

It explains what happens when you use Bookmark("whatever").Range.Text

There is a Sub there that you can use that accepts the bookmark name, and the bookmark text, as parameters. It is very similar to PH's code above. If you put text into bookmarks on a regular basis, it is best to put the FillABookmark sub in a module available globally. That way you can use it anywhere, anytime.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top