Greg
Wed Aug 02 19:36:06 CDT 2006
That's pay enough. Glad I could help.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Angyl wrote:
> That is perfection, Greg. Thank you very much!
>
> "Greg Maxey" wrote:
>
>> I've never done that before, but it seems if you had bookmarks of
>> the same name in a group of documents you could use something like
>> the below code in a command button event. Say you had two documents
>> Test1.doc and Test2.doc. Each had a bookmark named "Name" and
>> "Social." Create a userform with a textbox1 for name and textbox2
>> for social and a command button.
>>
>> Private Sub CommandButton1_Click()
>> Dim oRng As Word.Range
>> Documents.Open FileName:="C:\Test1.doc"
>> With ActiveDocument
>> Set oRng = .Bookmarks("Name").Range
>> oRng.InsertAfter Me.TextBox1
>> .Bookmarks.Add Name:="Name", Range:=oRng
>> Set oRng = .Bookmarks("Social").Range
>> oRng.InsertAfter Me.TextBox2
>> .Bookmarks.Add Name:="Social", Range:=oRng
>> .Save
>> .Close
>> End With
>> Documents.Open FileName:="C:\Test2.doc"
>> With ActiveDocument
>> Set oRng = .Bookmarks("Name").Range
>> oRng.InsertAfter Me.TextBox1
>> .Bookmarks.Add Name:="Name", Range:=oRng
>> Set oRng = .Bookmarks("Social").Range
>> oRng.InsertAfter Me.TextBox2
>> .Bookmarks.Add Name:="Social", Range:=oRng
>> .Save
>> .Close
>> End With
>> Me.Hide
>> End Sub
>>
>> --
>> Greg Maxey/Word MVP
>> See:
>>
http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
>>
>>
>> Angyl wrote:
>>> I don't get paid enough for this...
>>>
>>> I know how to create a user form.
>>> And I know how to use the ActiveDocument properties to automatically
>>> take data from the user form and put it into a document in form
>>> fields.
>>>
>>> What my boss wants now, is for that to work with MULTIPLE documents.
>>>
>>> I.E. a new employee comes in to our company and filles out a user
>>> form (document) asking basic info like name, social, phone numbers,
>>> address, etc. and when they are done:
>>>
>>> Word opens up employee profile.doc and fills in all the data in the
>>> form fields in there, then opens up the W--4 form and fills in all
>>> the data in the form fields in there, and opens up the I-9 form and
>>> fills in all the data in the form fields there...
>>>
>>> I guess my question is: how do I get VB to OPEN a document and
>>> propagate that data into the fields in it?