Printing from WebBrowser Control 
Author Message
 Printing from WebBrowser Control

I'm using the WebBrowser control in my VB project as PrintPreview and Print
control. The code in MSDN

Private Sub BtnPrint_Click()
        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
End Sub

works fine for Win98 and Win2000, but not on XP.
The QueryStatusWB returns 0, and wenn I'm trying ExecWB command I get
"Permission denied" error message.
What is the problem?

Ivan.



Mon, 16 May 2005 22:21:53 GMT  
 Printing from WebBrowser Control
You need to replace the parameters "",""with 0,0. One of the more recent
security updates of IE restricted print templates that are referenced using
those parms. Unless they are numeric zeroes, IE returns a permissions error.
In this particular case, a null string is not a zero.


Quote:
> I'm using the WebBrowser control in my VB project as PrintPreview and
Print
> control. The code in MSDN

> Private Sub BtnPrint_Click()
> 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
> End Sub

> works fine for Win98 and Win2000, but not on XP.
> The QueryStatusWB returns 0, and wenn I'm trying ExecWB command I get
> "Permission denied" error message.
> What is the problem?

> Ivan.



Wed, 01 Jun 2005 01:12:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. programmatically controlling header/footer on doc printed from WebBrowser control

2. How to customize or suppress header and footer when printing from WebBrowser control

3. Printing from WebBrowser control

4. Printing a Webbrowser control (also about Richtextboxes)?

5. Printing from WebBrowser control

6. Printing from WebBrowser control...

7. Can't print from WebBrowser Control

8. printing the WebBrowser control

9. How to customize/suppress header and footer when printing from WebBrowser control

10. Need help printing in webbrowser control

11. Can't print from WebBrowser control

12. Printing with WebBrowser Control

 

 
Powered by phpBB® Forum Software