G
Guest
I am trying to create a command button in an Access form to open a Word
document and print it to file. I have copied the Application.PrintOut command
which works in a Word macro, but Access VBA gives error message 'Compile
error. Method or data member not found.' I have checked that all the
references in Word VBA are also installed in Access VBA. Any suggestions? The
code is:
Private Sub Command157_Click()
Dim PrnDocName As String
PrnDocName = "c:\my documents 2\word
documents\electronicincorporation\memarts\DM" & _
Me![EnvelopeNumber] & ".MEM"
MergeNoPrompts "MEMART"
If Len(Dir$(PrnDocName)) > 0 Then
SetAttr PrnDocName, vbNormal
Kill PrnDocName
End If
ActivePrinter = "HP LaserJet IIP"
Application.PrintOut FileName:="MEMART", Range:=wdPrintRangeOfPages,
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2-20", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True,
Background:= _
True, PrintToFile:=True, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0,
OutputFileName:=PrnDocName, _
Append:=False
ActiveDocument.Close (wdDoNotSaveChanges)
End Sub
Thanks
Dudley
document and print it to file. I have copied the Application.PrintOut command
which works in a Word macro, but Access VBA gives error message 'Compile
error. Method or data member not found.' I have checked that all the
references in Word VBA are also installed in Access VBA. Any suggestions? The
code is:
Private Sub Command157_Click()
Dim PrnDocName As String
PrnDocName = "c:\my documents 2\word
documents\electronicincorporation\memarts\DM" & _
Me![EnvelopeNumber] & ".MEM"
MergeNoPrompts "MEMART"
If Len(Dir$(PrnDocName)) > 0 Then
SetAttr PrnDocName, vbNormal
Kill PrnDocName
End If
ActivePrinter = "HP LaserJet IIP"
Application.PrintOut FileName:="MEMART", Range:=wdPrintRangeOfPages,
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2-20", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True,
Background:= _
True, PrintToFile:=True, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0,
OutputFileName:=PrnDocName, _
Append:=False
ActiveDocument.Close (wdDoNotSaveChanges)
End Sub
Thanks
Dudley