I've created a word document that is like a form and I use this form on a daily basis at work. I am trying to make my life easier at work. I have built a userform with white text boxes for a word document that contains formfields. Can someone please share a code that may work. I would like to type in some text in the white boxe(s) on the userform and it will send that paticular text to the specified formfield. The white text box(s) should have the same value or text in the formfield. Example: white text box on the userform is called "txtname" and the formfield or bookmark on the word document is called "Text1". When I type the name David in the white text box called "txtname" and I then click a button that submitts it. I would like for word to send the name David, that is contained in "txtname", to the formfield called "Text1". Both "txtname" and "Text1" should have the same Name as David. I've tried several diffent codes and they will not work. I've tried everything and nothing seems to work. The code below is an example of what I've tried but it will not work. Your help is appreciated, please give me your input. Example(s) that will not work: ActiveDocument.FormFields(Text1) = txtname ActiveDocument.Forms(Text1) = txtname Text1.value = txtname txtname.value = Text1 ActiveDocument.Bookmarks(Text1) = txtname
See the article "How to create a Userform" at: http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm You use the .Result property of a formfield to assign something to it as shown in the following code: ActiveDocument.Formfields("Text1").Result = txtname I would suggest however that you use the same name for the bookmark assigned to the formfield as that as that of the name of the control on the userform. ActiveDocument.Formfields("txtname").Result = txtname -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "vdodd" wrote in message news:500C40DE-FCAA-4316-B6BF-FDC51429B8F9@microsoft.com... > I've created a word document that is like a form and I use this form on a > daily basis at work. I am trying to make my life easier at work. I have > built a userform with white text boxes for a word document that contains > formfields. Can someone please share a code that may work. I would like > to > type in some text in the white boxe(s) on the userform and it will send > that > paticular text to the specified formfield. The white text box(s) should > have > the same value or text in the formfield. Example: white text box on the > userform is called "txtname" and the formfield or bookmark on the word > document is called "Text1". When I type the name David in the white text > box > called "txtname" and I then click a button that submitts it. I would like > for word to send the name David, that is contained in "txtname", to the > formfield called "Text1". Both "txtname" and "Text1" should have the same > Name as David. I've tried several diffent codes and they will not work. > I've tried everything and nothing seems to work. The code below is an > example of what I've tried but it will not work. Your help is > appreciated, > please give me your input. > > Example(s) that will not work: > ActiveDocument.FormFields(Text1) = txtname > ActiveDocument.Forms(Text1) = txtname > Text1.value = txtname > txtname.value = Text1 > ActiveDocument.Bookmarks(Text1) = txtname > > >
Thanks Doug for your help. That solved my problem. "Doug Robbins - Word MVP" wrote: > See the article "How to create a Userform" at: > > http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm > > You use the .Result property of a formfield to assign something to it as > shown in the following code: > > ActiveDocument.Formfields("Text1").Result = txtname > > I would suggest however that you use the same name for the bookmark assigned > to the formfield as that as that of the name of the control on the userform. > > ActiveDocument.Formfields("txtname").Result = txtname > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP > > "vdodd" wrote in message > news:500C40DE-FCAA-4316-B6BF-FDC51429B8F9@microsoft.com... > > I've created a word document that is like a form and I use this form on a > > daily basis at work. I am trying to make my life easier at work. I have > > built a userform with white text boxes for a word document that contains > > formfields. Can someone please share a code that may work. I would like > > to > > type in some text in the white boxe(s) on the userform and it will send > > that > > paticular text to the specified formfield. The white text box(s) should > > have > > the same value or text in the formfield. Example: white text box on the > > userform is called "txtname" and the formfield or bookmark on the word > > document is called "Text1". When I type the name David in the white text > > box > > called "txtname" and I then click a button that submitts it. I would like > > for word to send the name David, that is contained in "txtname", to the > > formfield called "Text1". Both "txtname" and "Text1" should have the same > > Name as David. I've tried several diffent codes and they will not work. > > I've tried everything and nothing seems to work. The code below is an > > example of what I've tried but it will not work. Your help is > > appreciated, > > please give me your input. > > > > Example(s) that will not work: > > ActiveDocument.FormFields(Text1) = txtname > > ActiveDocument.Forms(Text1) = txtname > > Text1.value = txtname > > txtname.value = Text1 > > ActiveDocument.Bookmarks(Text1) = txtname > > > > > > > > >