Getting data from input box into MS Word Form

J

jim9912

I am using the following Macro to get data from the user via a popup
box. How can I then deposit the contents of the variable fname into a
form field on the parent document?

<code>
Sub Getinput()
Dim fname
fname = InputBox("Enter your name:")
End Sub
</code>


I tried this, where text10 is the name of the form field. I also tried
text10.text = fname.:
<code>
Sub Getinput()
Dim fname
fname = InputBox("Enter your name:")
text10 = fname
End Sub
</code>

I'm sure the answer must be simple, but alas, I am a novice.
 
H

Helmut Weber

Hi Jim,

like this:

ActiveDocument.FormFields("Text1").Result = "xxx"

whereby "xxx" is what your inputbox returns.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
C

Charles Kenyon

Also, to prevent errors like this in the future, you may want to turn the
option explicit on in your vba.

Option Explicit

This goes at the beginning of a module and forces declaration of all
variables.

--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide




--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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