|
-
Mar 22nd, 2003, 02:09 PM
#1
Thread Starter
New Member
inserting records into a word document
I have a standard word document with bookmarks and a vb6 form where the user selects multiple names from a list box.
what i want to do is when the user selects three names from the listbox. I want to be able to take the three names query the access database open the word document and populate the necessary filds in the appropriate bookmark.
I have a standard letter which is saved in test .doc with the necessary bookmarks. and when the user selects four records from a listbox, I want to open this document and give the user the user the ability to view and print the letter for each record selected. the problem with opening and saving one document each for each records is that the user will have to open twenty documents if they select twenty records. that's why I want to use one document to show all of the letters that will be printed for each record selected. in other words if I wnat to send twenty letters to twenty people all of them with the same content except for the inserted records, I want to see all of my letters in one document. this is what i have so far
openDB (sqlstring)
If rsObj.RecordCount = 0 Then
Exit Function
End If
Set objWord = CreateObject("Word.Application")
While Not rsObj.EOF
With objWord
.Visible = True
.Documents.Open (strDocPath)
.ActiveDocument.Bookmarks("name").Select
.Selection.Text = rsObj.Fields("name")
.ActiveDocument.Bookmarks.Add Name:="name"
Range = .Selection.Range
End With
rsObj.MoveNext
Wend
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|