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

Print HTML Page from VB - Runtime error 91

Status
Not open for further replies.

luanahubbart

Programmer
Jul 28, 2004
18
US
I am trying to print an HTML page from VB6. I have tried various methods I have seen here on Tek Tips. when I try to use Navigate it gets a 'runtime 91 error' with clause or object variable not set. Highlights .navigate
I have tried

Dim strhtml As String
Dim wb1 As WebBrowser

wb1.Navigate App.Path & "\myfile.html"
and
With wb1
.Navigate App.Path & "\Blank Incident Report.html"
While .StillExecuting = True
strhtml = .GetChunk(1024)
MsgBox " " & strhtml
Wend

End With

What to do? Thanks for your help!
 
Hi Luana,

As far as I can see (and people please put me right if I'm not) there are a couple of problems with your code example:

Code:
Dim wb1 As WebBrowser

If you have the WebBrowser control on the form you don't have to declare it.

Code:
wb1.Navigate App.Path & "\myfile.html"
and

Why do you have the 'and' in? That will cause it to error.

Code:
While .StillExecuting = True
strhtml = .GetChunk(1024)

I'm not 100% on this but I think .StillExecuting and .GetChunk are for use with Databases and are not supprted by the WebBrowser control? Could anyone confirm or deny this for me??

Hope this helps

Harleyquinn
 
What I meant with the 'and' is I have tried both ways and it didn't work, it kept on giving me an error when I tried to navigate. I do not have the WebBrowser control on my form.

I tried the while executing bit, because I thought that might help. I did have it without that part also.

Thanks, for your help! Sorry you misunderstood.
 
So all OK now that you've put the control on your Form?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Hi Luana,

If you place a webbrowser control on your form, navigate to the page you want on Form_Load for example and place this on say, a button click event.

Code:
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER

That will print your web page.

On a final note which I have just rememembered you may want to paste these into a module:

Code:
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDID_PRINT = 6

Hope this helps

Harleyquinn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top