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

How to Print Word/Excel file direct to printer without opening that fi

Status
Not open for further replies.

khcheong

Programmer
Oct 5, 2000
13
0
0
MY
Is anyone know how to send a word document or a excel file direct to printer without open the file? Is there any command to do this?

Is just like from the windows explorer we point the mouse pointer to that file and right click and select the print to send to the printer.

I need this command to built in my application so that the userscan select a word document or a excel file by specify the filename and file path and then press a button to directly send to the printer.

Thanks
 
You can use ShellExecute API function, and print without opening the application.

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Public Sub PrintDocument(ByVal sDocumentName As String)
Const SW_HIDE = 0
Dim lRet As Long
lRet = ShellExecute(Me.hwnd, "Print",DocumentName, "", "", SW_HIDE)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top