Re: How to print from VB
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Sat, 2 Apr 2005 09:30:52 -0500
Whoops! Forgot the declarations.
Private 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
Private Const SW_HIDE = 0
--
Mike
Microsoft MVP Visual Basic
"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:OOCNM$4NFHA.2748@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Jenny Smith" <j_a_smith@xxxxxxxxxxx> wrote in message
> news:inl3e.7447$V62.3849@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > Hello,
> >
> > Hope anyone can help me with this problem. I need to be able to allow
> user
> > to print any Windows App files from my VB program, such as .doc, .pdf,
> .txt,
> > .wri ....
>
>
> If all the file types you want to print are associated with an
application,
> you can use this:
>
> Dim sFileToPrint As String
> Dim lRet As Long
>
> 'Path is hard-coded for example purposes only
> sFileToPrint = "C:\MyApp\MyFile.doc"
>
> lRet = ShellExecute(Me.hwnd, "print", sFileToPrint, vbNullString,
> vbNullString, SW_HIDE)
> If lRet < 33 Then
> MsgBox "Unable to print"
> End If
>
> You might want to use a Select Case on the return value and provide better
> information as to why it couldn't print. Look up ShellExecute in the
> Platform SDK for the meanings of all its return values. Also note that
just
> because SW_HIDE was specified, the app *may* still briefly appear.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
.
- References:
- How to print from VB
- From: Jenny Smith
- Re: How to print from VB
- From: MikeD
- How to print from VB
- Prev by Date: Re: How to print from VB
- Next by Date: Old Subject: Explorer Messages
- Previous by thread: Re: How to print from VB
- Next by thread: Re: How to print from VB
- Index(es):
Relevant Pages
|