Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re: Web Browser Printing error


Message #1 by "Huw Wigley" <hgwigley@a...> on Thu, 15 Aug 2002 11:25:29
Seth,

I had also experienced that problem, the problem is due to a 
security 'fix' put into IE, to get around it, I used the following code - 

Dim eQuery As OLECMDF       'return value type for QueryStatusWB
On Error GoTo PrintError

    Screen.MousePointer = vbHourglass
    eQuery = WebBrowser1.QueryStatusWB(OLECMDID_PRINT)  
    If eQuery And OLECMDF_ENABLED Then
        WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
    Else
        MsgBox "The Print command is currently disabled."
    End If

PrintExit:
    Screen.MousePointer = vbDefault
    Exit Sub
PrintError:
    MsgBox "Print command Error: " & Err.Number & " : " & Err.Description
    GoTo PrintExit

As you can see the only difference is I have left out the 3rd and 4th 
parameters on the ExecWB statement.

Hope this helps,

Huw Wigley

> Seth,
> 
> I have just recently experienced the same problem with code that has 
been 
> in production for two or three years... It is an apparent change in the 
> way IE6 handles the printing, not the OS.  Unfortunately, I don't have a 
> good solution for you other than the ability to right-click on the page 
in 
> the browser control and selecting Print.  I searched MS website and this 
> is still published as the way to print the webBrowser control from VB 
with 
> IE 4+.
> 
> If you have found a better solution, please let me know.
> 
> Thanks and Good Luck,
> Richard A. Neuendorff
> 
> 
> > I'm using this code to  print from a web browser control:
> > Dim eQuery As OLECMDF       'return value type for QueryStatusWB
> > 
> > On Error Resume Next
> > eQuery = WebBrowser1.QueryStatusWB(OLECMDID_PRINT)  'get print
> > command status
> > If Err.Number = 0 Then
> >     If eQuery And OLECMDF_ENABLED Then
> >         WebBrowser1.ExecWB OLECMDID_PRINT, 
> OLECMDEXECOPT_PROMPTUSER, "", ""
> > 'Ok to Print?
> >   Else
> >         MsgBox "The Print command is currently disabled."
> >     End If
> > End If
> > If Err.Number <> 0 Then MsgBox  "Print command Error:  & 
Err.Description"
> > 
> > When I try to run it, I get this error message: Permission Denied.
> > Why?
> > I'm running Windows 98, if that makes any difference.
> > Seth Bembeneck
> > 

  Return to Index