VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Shell Print Any Document

Jay Kreusch  (6 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Easy code allows you to print any document on the computer using its default print handler. This is the same as if you right-click in the windows explorer and select Print. No command switches are needed. So simple I added a handy ShellExecute Error Handler.

Inputs
To make it a public function for use in a bas, I use the form's Hwnd as a parameter. This hwnd is only used to retrieve errors. So if you only care about pass/fail you could leave that part out. Just pass the function the hwnd and the path to the file and call.

API Declarations
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 Const SE_ERR_FNF = 2&
Private Const SE_ERR_PNF = 3&
Private Const SE_ERR_ACCESSDENIED = 5&
Private Const SE_ERR_OOM = 8&
Private Const SE_ERR_DLLNOTFOUND = 32&
Private Const SE_ERR_SHARE = 26&
Private Const SE_ERR_ASSOCINCOMPLETE = 27&
Private Const SE_ERR_DDETIMEOUT = 28&
Private Const SE_ERR_DDEFAIL = 29&
Private Const SE_ERR_DDEBUSY = 30&
Private Const SE_ERR_NOASSOC = 31&
Private Const ERROR_BAD_FORMAT = 11&

Rate Shell Print Any Document (6(6 Vote))
Shell Print Any Document.bas

Shell Print Any Document Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters