Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open word doc to print only

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
Is there a way to open up a word document to print it using VBA.... similiar to the right click, print when in explorer?

Bill
 
You can try something like this...

Public Sub mOpenWord()
Dim appWord As New Word.Application
Dim intResponse As Integer

'Open word with specified file
appWord.Documents.Open ("c:\TEST\TEST.DOC")
'print file
appWord.PrintOut

'set default response
intResponse = vbYes

'loop while response is yes
Do While intResponse = vbYes
intResponse = MsgBox("Reprint ?", vbYesNo)
'if reprint is no then close and exit word
If intResponse = vbNo Then
appWord.Documents.Close (False)
appWord.Quit (False)
Set appWord = Nothing
Else
'Reprint document
appWord.PrintOut
End If
Loop

End Sub

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top