chainedtodesk
Programmer
i have a current process that takes data from a name and address table and with a template generates individual word docs, which get printed and mailed (works Fine). our mailroom recently upgraded to a new printer, and has requested that the word doc's anywhere from 10-2500 be bundled to one document for ease in spooling. i can not get this to work. can it be done? Thanks
Access 2003 .ADP code to follow
Private Sub GenInvites_Click()
DoCmd.SetWarnings False
'Open Word, import the text to the bookmarks and display the letter
Set objWord = New Word.Application
objWord.Visible = False 'was True
'Open Your Recordset and move to the first record
Dim Conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Set Conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "Select * from dbo.Invitations_ToGo"
rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
'Loop through each record of the Rs, inserting each field of the record into a Bookmark in the template
Do Until rs.EOF
Set objworddoc = objWord.Documents.Add(Template:="\\vo-alb-fs01\empireQM\dm_inputs\Invite.dot", NewTemplate:=False)
With objworddoc
.Activate '<------- important
.Bookmarks("Date").Range.Text = rs!fmtDS & vbCrLf & vbCrLf
.Bookmarks("InviteInfo").Range.Text = RTrim(rs![First Name]) & " " & RTrim(rs![Last Name]) & vbCrLf & RTrim(rs![Address 1]) & " " & RTrim(rs![Address 2]) & vbCrLf & RTrim(rs!City) & ", " & RTrim(rs!State) & " " & RTrim(rs!Zipcode) & vbCrLf & vbCrLf
End With
'Save the letter to the desired folder
Dim strhdr1 As String
strhdr1 = rs![Last Name] & "_" & rs![First Name] & "_" & rs![fmtdate]
objworddoc.SaveAs Filename:="\\Mailroom\CurrentMonth\Invitation_" & strhdr1 & ".doc"
'objworddoc.PrintOut
objworddoc.close
Set objworddoc = Nothing
rs.MoveNext
Loop
objWord.Quit
Set objWord = Nothing
MsgBox "Invitation Process Is Complete, Mailroom Can Be Notified To Print", vbOKOnly
End Sub
Access 2003 .ADP code to follow
Private Sub GenInvites_Click()
DoCmd.SetWarnings False
'Open Word, import the text to the bookmarks and display the letter
Set objWord = New Word.Application
objWord.Visible = False 'was True
'Open Your Recordset and move to the first record
Dim Conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Set Conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "Select * from dbo.Invitations_ToGo"
rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
'Loop through each record of the Rs, inserting each field of the record into a Bookmark in the template
Do Until rs.EOF
Set objworddoc = objWord.Documents.Add(Template:="\\vo-alb-fs01\empireQM\dm_inputs\Invite.dot", NewTemplate:=False)
With objworddoc
.Activate '<------- important
.Bookmarks("Date").Range.Text = rs!fmtDS & vbCrLf & vbCrLf
.Bookmarks("InviteInfo").Range.Text = RTrim(rs![First Name]) & " " & RTrim(rs![Last Name]) & vbCrLf & RTrim(rs![Address 1]) & " " & RTrim(rs![Address 2]) & vbCrLf & RTrim(rs!City) & ", " & RTrim(rs!State) & " " & RTrim(rs!Zipcode) & vbCrLf & vbCrLf
End With
'Save the letter to the desired folder
Dim strhdr1 As String
strhdr1 = rs![Last Name] & "_" & rs![First Name] & "_" & rs![fmtdate]
objworddoc.SaveAs Filename:="\\Mailroom\CurrentMonth\Invitation_" & strhdr1 & ".doc"
'objworddoc.PrintOut
objworddoc.close
Set objworddoc = Nothing
rs.MoveNext
Loop
objWord.Quit
Set objWord = Nothing
MsgBox "Invitation Process Is Complete, Mailroom Can Be Notified To Print", vbOKOnly
End Sub