T
tcek
I have a batch file that loads a Word document and then runs a macro that
inserts MS query results into a standard form letter. The batch file will
run and load everything but the data does not appear in the printed output.
the batch file and macro appear below
Batch file to open document, print the form letter and close Word:
C:\Program Files\Microsoft Office\Office\WINWord.exe"
p:\private\TC\CLINSRV\AccessPrograms\EPOMonitoringPage1.doc
/mEPOMonitoringForm /mfileprintdefault /mpausemacroafterprinting /mfileexit
exit
Macro to insert MS query data:
Sub EPOMonitoringForm()
'
' EPOMonitoringForm Macro
' Macro recorded 8/22/2007 by TC,
'
ChangeFileOpenDirectory "P:\private\TC\CLINSRV\AccessPrograms\"
Documents.Open FileName:="EPOMonitoringPage1.doc", ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
With Dialogs(wdDialogFilePrint)
.Execute
End With
End With
End With
End Sub
inserts MS query results into a standard form letter. The batch file will
run and load everything but the data does not appear in the printed output.
the batch file and macro appear below
Batch file to open document, print the form letter and close Word:
C:\Program Files\Microsoft Office\Office\WINWord.exe"
p:\private\TC\CLINSRV\AccessPrograms\EPOMonitoringPage1.doc
/mEPOMonitoringForm /mfileprintdefault /mpausemacroafterprinting /mfileexit
exit
Macro to insert MS query data:
Sub EPOMonitoringForm()
'
' EPOMonitoringForm Macro
' Macro recorded 8/22/2007 by TC,
'
ChangeFileOpenDirectory "P:\private\TC\CLINSRV\AccessPrograms\"
Documents.Open FileName:="EPOMonitoringPage1.doc", ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
With Dialogs(wdDialogFilePrint)
.Execute
End With
End With
End With
End Sub