VBA Reading a Word Document's Form Field into a User Form Text Box

B

Brendan

How do I grab the value from an Form Field in an active document and then
place that value into a User Form that has a corresponding text box. I
thought it would be something like this but I can’t seem to get it to work.


Private Sub UserForm1_Initialize()

Me.tbLastFirstMiddle.Value = ActiveDocument.FormFields("docLastFirstMiddle")

End Sub
 
B

Brendan

Found my own solution: Had to actually call the form [UserForm1] and forgot
the [Result] tag. Works fine.

UserForm1.tbLastFirstMiddle =
ActiveDocument.FormFields("docLastFirstMiddle").Result
 
J

Jean-Guy Marcil

Brendan was telling us:
Brendan nous racontait que :
Found my own solution: Had to actually call the form [UserForm1] and
forgot the [Result] tag. Works fine.

Actually, you could have use the Me keyword inside the Userform Initialize
event.
You were right about the Result property though.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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