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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I repeat a BOOKMARK in Word 2000? 1

Status
Not open for further replies.

cjkoontz

MIS
Aug 9, 2000
102
US
Is it possible (then how) to repeat a bookmark in a Word 2000 doc?

Let's say that I want to repeat the [NAME] of a person throughout a document.

TIA.
 
Thanks for the reply. I'm trying to do something like this (repeat the [INSPECTOR] bookmark in a couple places in a document:

...
Please contact [INSPECTOR] at the following phone number.
...
Sincerely,
[INSPECTOR]
Housing Inspector

Unfortunately, I am using a third party software company's interface to Word 2000. There is no mailmerge file available -- just bookmarks.
 
So with this 3rd party software, it definitly has to be bookmarks? I have tried, but I really don't think it can repeat the bookmark. There might be another way, but I can't think of anything. I was going to suggest using mail merge but it sounds like you already know that won't work. Anyone else????

Sorry,

Dawn
 
normally you would solve this using REF fields. But I don't now if they are provided in your 3rd party interface.

But anyway: if the bookmark is [INSPECTOR] is placed in your document you can insert a REF field linked to this bookmark. (Insert - Field - REF). When you check the Fieldcodes box in Tools - Options this field would look like this: { REF INSPECTOR }
 
If you wanting it to move to the bookmark INSPECTOR... have you considered having a hyperlink to the bookmark?
 
Thanks. The REF field appears to be a great solution. Here's what I did --

*** Enabling field codes.
Click Tools,
Click Options,
Click View tab,
Click Field codes (in the Show section),
[Optional] Click Always (in the Field shading drop down).

*** Inserting REF BOOKMARK.
Position cursor to desired insertion point.
Click Insert,
Click Field,
Click Links and References (from the Categories box),
Click Ref (from the Field names box),
Type the name of the bookmark in the Field codes input box.

(To be on the safe side, I made sure that I was inserting a predefined bookmark.)
 
I've tried using the REF BOOKMARK approach but I can't get the VBA code to insert the data at the second instance of the bookmark. Any tips or sample code to help with this problem?
 
Try to record a macro that does just this:

Tools -> Macro -> Record New Macros, etc.

Then go through the motions to replace all instances of the bookmark:

Edit -> Replace -> etc. -> Replace All.

Stop the macro record and examine the code.
 
Thanks for the Find/Replace method (which definitely works). It's unusual that there isn't a simpler solution for a circumstance that I am sure people encounter all the time (needing to populate multiple instances of a bookmark with the same data). Thanks again!
 
I can't seem to get the Find/REplace method to work for multiple fields. Here is the code I was using for the REF MERGEFIELD attempt. Any suggestions as to why it is not inserting the text in the second instance of the bookmark?

Private Sub cmdOK_Click()

Application.ScreenUpdating = False

With ActiveDocument
.Bookmarks("Recipient").Range.Text=
txtRecipient.Value
End With

Application.ScreenUpdating = True
Unload Me
End Sub

Thanks!
 
Create a property called Inspector in File|Properties and Custom tab.

Now whereever you need this value in the document put a field {DOCPROPERTY "Inspector"}.

Use the old Ctrl-A, F9 trick to refresh fields whenever you change the value of Inspector under File|Properties and hey presto!

I use this technique all the time. It works, it's simple and it saves time. Only problem is that most people using my templates type over the field instead of changing the property but I haven't found a solution to that.

 
plantj has a good idea with using DocProperty. A possible solution to his problem with users typing over the field is to embed the field code in a form field. That way the Ctrl-A-F9 will always revert the form field to its original value, that is, the value of the field code inside it. Users can type whatever they want into the form field, it will look differently, but a refresh will bring back your value. Of course if they deliberately edit the form field itself....you could always do continous section breaks, locking the forms etc. etc.

The following will insert a form field, with the DocProperty value, anywhere you want, as many times as you want.

Sub MakeFieldInForm()

' make a form field and insert a field code
'
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With Selection.FormFields(1)
.Name = "Text1" ' or whatever you like
.Enabled = False
With .TextInput
' insert a field code into text value of form field
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="DocProperty""MyField"""
' MyField could be a string variable
' selected from a user form listing all
' of your custom docproperties
End With
End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top