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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing without opening MS Word

Status
Not open for further replies.
Mar 19, 2003
57
US
I am using the Shell API to attempt to print a MS Word Document without having MS Word opened. However, this Shell API always opens MS Word in order to print the document. What am I missing here?

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long

Private Sub Form_Load()

Dim StartPrint As Long
Dim FileToPrint As String

FileToPrint = "D:\Data\test.doc"
StartPrint = ShellExecute(Me.hwnd, "open", FileToPrint, ByVal 0&, ByVal 0&, SH_HIDE)

End Sub
 
I meant to write "print" as oppose to "open" in the code below.

StartPrint = ShellExecute(Me.hwnd, "print", FileToPrint, ByVal 0&, ByVal 0&, SH_HIDE)
 
You aren't missing anything, that's the way shell extensions like open and print work. Have you tried automating Word, opening the doc and printing it? Although this involves opening Word, the Visible property of the Word Application object can be set to False so the user doesn't see it.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top