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

Need to Print a File while running VB6

Status
Not open for further replies.

bighavlo

Programmer
Jul 14, 2003
19
0
0
US
I need to print a word document or a picture without editing it. Is there anyway to just print a document through VB6??? - Thanks
 
Search for the ShellExecute API function. You specify a filename and the "print" verb and the function will open the file in its registered application and print it.

Paul Bent
Northwind IT Systems
 
Could you give me an example. I tried looking it up and using diff code but nothing works.
 
Code:
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

Const SW_SHOWMAXIMIZED = 3 'Show the opened window maximized
Const SW_SHOWMINIMIZED = 2  'Show the opened window minimized
Const SW_SHOWMINNOACTIVE = 7 'Show the opened window minimized but do not activate the it
Const SW_SHOWNA = 8 'Show the opened window in its current
state but do not activate it
Const SW_SHOWNOACTIVATE = 4 'Show the opened window in its most recent size and position but do not activate it
Const SW_SHOWNORMAL = 1   'Show the opened window and activate it (as usual)

Sub sPrintDoc(Byval strFile As String)

 'Given a file, calls ShellExecute to print it

 ShellExecute Me.hWnd, "print", strFile, vbNullString, _
 vbNullString, SW_SHOWNORMAL

End Sub

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

Part and Inventory Search

Sponsor

Back
Top