Article ID: 154569
Article Last Modified on 1/19/2007
For Microsoft Word 97:
Function PrintDoc()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "C:\Wordtest.doc"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Function
For Microsoft Word 7.0:
Function PrintDoc()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")
WordObj.FileOpen "C:\Wordtest.doc"
' Where 2 is the number of copies. In this example, the parameter
' names have been included to show which argument does what.
WordObj.FilePrint Background:=0, AppendPrFile:=0, Range:=0, _
PrToFileName:="", From:="", To:="", Type:=0, NumCopies:=2
' The following line demonstrates how to preview instead of print
' WordObj.FilePrintPreview.
' Close without saving.
WordObj.FileClose 2
Set WordObj = Nothing
End Function
? PrintDoc()
Name: PrintDoc
Caption: Print Word Doc
OnClick: [Event Procedure]
For Microsoft Word 97:
Private Sub PrintDoc_Click()
Dim WordObj As Object
Me![OLEObj].Verb = -2 'Tells Access to open the application
Me![OLEObj].Action = 7 'Activates the application
Set WordObj = Me![OLEObj].Object.Application
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Sub
For Microsoft Word 7.0:
Private Sub PrintDoc_Click()
Dim WordObj As Object
Me![OLEObj].Verb = -2 'Tells Access to open the application
Me![OLEObj].Action = 7 'Activates the application
Set WordObj = Me![OLEObj].Object.Application.WordBasic
' This example prints the current document using FilePrintDefault.
WordObj.FilePrintDefault
' The following line demonstrates how to preview instead of print.
' Comment out the FileClose method that follows, in order to leave
' Print Preview open.
' WordObj.FilePrintPreview
WordObj.FileClose 2
End Sub
Keywords: kbhowto kbinterop kbprogramming KB154569