Creating a helpful hint pop-up

E

Erik Thoresen

I've tried this help there, but it didn't help me.

When creating the userform it doesnt work quite as i would like:
In modules:
Sub AutoNew()
'
' AutoNew Makro
'
'
UserForm1.Show

End Sub
Loads the form
then in forms:
Private Sub CommandButton1_Click()
With ActiveDocument.Bookmarks("bmKursdato").Range.Fields(1).Result.Text = TextBox1
.Bookmarks("bmKurstid").Range.Fields(1).Result.Text = TextBox2
.Bookmarks("bmTamed").Range.Fields(1).Result.Text = TextBox3
End With
UserForm1.hide
End Sub
The first line responds fine with the textfield in the doc, but for the next lines noting.
The info in link did nothing like expected.

This was a simple pop up, with three txtboxes to fill in to a document with standarized text
I am a newbie
 
J

Jay Freedman

You got the syntax messed up. The "With" line should contain only
ActiveDocument, and the rest of that line should be moved to the next line:

With ActiveDocument
.Bookmarks("bmKursdato").Range.Fields(1).Result.Text = TextBox1
.Bookmarks("bmKurstid").Range.Fields(1).Result.Text = TextBox2
.Bookmarks("bmTamed").Range.Fields(1).Result.Text = TextBox3
End With

If the "fields" you have in the document are actually text formfields, then it
should really be

With ActiveDocument
.FormFields("bmKursdato").Result = TextBox1.Text
.FormFields("bmKurstid").Result = TextBox2.Text
.FormFields("bmTamed").Result = TextBox3.Text
End With
 

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