Cross Referencing bookmarks created by a Userform

D

Darren Ingram

Hi all,

I've created a letter which pops up a Userform which the user completes and
the information is inserted into the letter. Rather than create multiple
bookmarks in the letter for the user's name (ie multiple entries of the same
data in the userform), I've thought about cross-referencing a single bookmark
and have that information inserted at multiple points in the document.

This is where the problem starts. I insert a cross reference into the
document (stating that it is Reference Type: Bookmark and Insert reference
to: Bookmark text) ...nothing comes up to show that a cross-reference is
inserted (as a bookmark would show - is this normal?) also, when I run the
document using the Userform I get blank fields as a result.

Any assistance would be appreciated!!
 
D

Darren Ingram

Thanks Suzanne,

I'm a little bit of a novice when it comes to Userforms....Would you add
your code within the Private Sub CommandBUtton1_Click() code but before the
userform bookmarks being activated (as below) or would you run it at the end?
Would my coding look like this from the CommandButton?

I feel there is much to learn about the Userform/bookmark process....(I'm
sure you are rolling your eyes as you say "Uh huh!!"

Thanks for your help.
_____________________________________

Private Sub CommandButton1_Click()

Sub UpdateBookmark(BookmarkToUpdate As String, TextToUse As String)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
BMRange.Text = TextToUse
ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
End Sub

With ActiveDocument
..Bookmarks("Officer_firstname").Range _
..InsertBefore TextBox1
..Bookmarks("Officer_familyname").Range _
..InsertBefore TextBox2
..Bookmarks("Officer_telephone").Range _
..InsertBefore TextBox3
..Bookmarks("Officer_phoneextension").Range _
..InsertBefore TextBox4
..Bookmarks("Officer_emailname").Range _
..InsertBefore TextBox5
..Bookmarks("Client_title").Range _
..InsertBefore TextBox6
..Bookmarks("Client_firstname").Range _
..InsertBefore TextBox7
..Bookmarks("Client_familyname").Range _
..InsertBefore TextBox8
..Bookmarks("Todays_date").Range _
..InsertBefore TextBox9
End With

UserForm2.Hide

End Sub
 
S

Suzanne S. Barnhill

*I* would not do anything since I have no expertise in VBA (and consequently
am not rolling my eyes at all). You might want to post in the
microsoft.public.word.vba.userforms newsgroup for more expert help.
 
D

Darren Ingram

Suzanne,

Thanks for that.... I'm an 'expert' (I use that term very loosely) in many
things related to Office (to a point)....But when I start playing with VBA
macro writing with User forms I've certainly hit that point. Oh well, it's
all about learning isn't it? When I find my answer I'll attach it to this
thread so that you've the opportunity to add it to you arsenal of knowledge.
Thanks once again. - Darren
 

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