View Single Post
 
Old 05-04-2015, 03:21 AM
rogelinepaula rogelinepaula is offline Windows 8 Office 2013
Novice
 
Join Date: May 2015
Posts: 22
rogelinepaula is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
You only neeed 1 userform, with several fields. For a relatively simple description, see http://www.gmayor.com/Userform.htm That example uses docvariables and their associated fields rather than bookmarks, but if you want to fill bookmarks instead see the FillBM function at http://www.gmayor.com/word_vba_examples.htm
Thank you, gmayor!

I have seen a YouTube tutorial and I basically followed everything. I got the UserForm that I want once you open the document but for some reason the "Client" field which I have bookmarked in the document isn't being populated by whatever it is that I am typing in the userform under the Client field.

Here's the code that I've been using:
Quote:
Private Sub CommandButton1_Click()
Dim RepTitle As Range
Set RepTitle = ActiveDocument.Bookmarks("RepTitle").Range
RepTitle.Text = Me.TextBox1.Value
Dim ReportDate As Range
Set ReportDate = ActiveDocument.Bookmarks("ReportDate").Range
ReportDate.Text = Me.TextBox2.Value
Dim Client As Range
Set Client = ActiveDocument.Bookmarks("Client").Range
Client.Text = Me.TextBox3.Value
Dim ContactName As Range
Set ContactName = ActiveDocument.Bookmarks("ContactName").Range
ContactName.Text = Me.TextBox4.Value
Dim ContactAdd As Range
Set ContactAdd = ActiveDocument.Bookmarks("ContactAdd").Range
ContactAdd.Text = Me.TextBox5.Value
Dim DivInCharge As Range
Set DivInCharge = ActiveDocument.Bookmarks("DivInCharge").Range
DivInCharge.Text = Me.TextBox6.Value
Me.Repaint
UserForm1.Hide


End Sub
I am using Word 2013. Should that be an issue re bookmarks? And also, how do I make the userform disappear as soon as I hit the "OK" button?


Thank you for all the help!
Reply With Quote