PDA

View Full Version : Solved: User Form Help



bryan
02-23-2005, 01:52 PM
I am quite new to VBA and need some help with a user form I have created.

I have a few fields on the user form which I want the user to fill in. once this has been completed I would then like this info to be transferred to certain fields in a word document. I have already marked out the fields using bookmarks but I am have trouble transferring the text to the fields:banghead:

Howard Kaikow
02-23-2005, 02:15 PM
That's a very general question.

One place to start may be with Steve Roman's Writing Word Macros book.
Alse, see http://www.standards.com/index.html?WordVBABooks.

mdmackillop
02-23-2005, 02:50 PM
Hi Bryan,
Have a look at this KB item which contains a few demonstration samples.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=184
If you need more assistance, let us know.
MD

TButhe
02-23-2005, 03:39 PM
Just had this same question and found it in a thread here but can't remember which one. Anyway you will need a command button on your user form and then you will need to place bookmarks in your document where you want the text to be and name them something unique like Date, or ContactName. You will also need to know the name of your text box on your user form. Once that is done you will need to add the code to the button you placed on the user form. Here is some sample code.


Private Sub cmdOK_Click()
'my command button is named "cmdOK" without the quotes
Selection.GoTo What:=wdGoToBookmark, Name:="Date"
'where "Date" is put the name of your Bookmark but this time use the quotes
Selection.Range.Text = Me.tbDate.Text
'Where tbDate is - use the name of the text box that you are
'capturing the data in on your user form mine happens to be "tbDate"

End Sub


Hope this helps! I have to run so please forgive me if I forgot anything!! :hi:

newk
02-25-2005, 08:47 AM
Hiya Bryan,

If your still struggling post an example and I'd be glad to help, I learnt from the master DRJ.

TButhe is spot on however I find basic names helpful so here you are.


Private Sub CommandButton1_Click()
Selection.GoTo What:=wdGoToBookmark, Name:="Bookmark1"
Selection.Range.Text = Me.TextBox1.Text
Unload Me
End Sub

bryan
02-26-2005, 03:18 PM
thanks for your help everyone. sorry i have not replied I have had a few PC problems!. I have managed to work this out with all your help, really appreciate it!