Additional bookmarks needs

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Additional bookmarks needs

Post by ABabeNChrist »

I am using a UserForm to update client information to bookmarks, I need to duplicate this same data to mutable locations. I tried Special Paste / Paste link, that works OK until the target link has no data then when you close and save link is broken. I know that only 1 bookmark with same name can be used, I was thinking of using a sequence like ClientInfo1, ClientInfo2, ClientInfo3 .
here part of the code I was using

Code: Select all

Dim oRng As Word.Range
Dim oBM As Bookmarks
Set oBM = ActiveDocument.Bookmarks

Set oRng = oBM("ClientName").Range
oRng.Text = Me.TextBox1.Text
oBM.Add "ClientName", oRng

Set oRng = oBM("ClientAddress").Range
oRng.Text = Me.TextBox2.Text
oBM.Add "ClientAddress", oRng

Set oRng = oBM("ClientCity").Range
oRng.Text = Me.TextBox3.Text
oBM.Add "ClientCity", oRng
I tried using
Set oRng = oBM("ClientInfo1, ClientInfo2, ClientInfo3 ").Range
and
Set oRng = oBM("ClientInfo1”, “ClientInfo2”, “ClientInfo3 ").Range
no suck luck
Also I would get an error if all textboxes were not used

User avatar
StuartR
Administrator
Posts: 12617
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Additional bookmarks needs

Post by StuartR »

One way you could do this is to use references for your second and subsequent copies of the name

The code could remain the same, but you would have just one ClientName bookmark, the other places that you want this text to appear would contain the field
{ REF ClientName }

To make sure that the references update when you change the Client Name you could add ActiveDocument.Fields.Update
to the end of your code. If you have fields in headers, footers or text boxes then you will need more complex code to update these as well.

If you want to use multiple bookmarks then you will need to update each one separately, like this...
Set oRng = oBM("ClientName").Range
oRng.Text = Me.TextBox1.Text
oBM.Add "ClientName", oRng

Set oRng = oBM("ClientName1").Range
oRng.Text = Me.TextBox1.Text
oBM.Add "ClientName1", oRng

etc.
StuartR


ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Additional bookmarks needs

Post by ABabeNChrist »

Thank you StuartR
I think I’ll try to reference each of the bookmarks first and see how that works for me.