Click to See Complete Forum and Search --> : Printing Question
bmoffatt
Jan 28th, 2000, 01:47 PM
I've created a VB6 project that includes an internet browser using the MS Browser OCX control. Printing in VB is not very well documented unless I want to print an ellipse. Is there code that would grab the contents of the browser and send it to the Windows printer, or do I just not understand?
Aaron Young
Jan 28th, 2000, 02:08 PM
Use the WebBrowser's ExecWB Method with the OLECMDID_PRINT Constant, i.e.
Private Sub Command1_Click()
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
End Sub
To Prompt the user to Select a Printer, etc, change OLECMDEXECOPT_DONTPROMPTUSER with OLECMDEXECOPT_PROMPTUSER .
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
bmoffatt
Jan 29th, 2000, 05:02 AM
I tried the ExecWB method exactly as quoted, and get an error "Run-time error '-2147221248 (80040100)0:' Method 'ExecWB' of object 'IWebBrowser2' failed.
It worked once when I changed OLECMDEXECOPT_DONTPROMPTUSER to PROMPTUSER, then not again. Any ideas?
Aaron Young
Jan 29th, 2000, 05:51 AM
ExecWB would only Fail if the Print Operation wasn't successfull, ie.
The Printer was offline, not connected, or the User Canceled the Print Dialog, (if you prompted with one).
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
bmoffatt
Jan 29th, 2000, 01:40 PM
Apparently, the error means "Trying to revoke a drop target that has not been registered." Being a newbie, this doesn't tell me much. Is there a variable I need to declare inorder to use ExecWB correctly? What am I missing?
bmoffatt
Jan 31st, 2000, 08:43 AM
The printer is on, connected, on line, and otherwise working perfectly. I found out that if I use "debug" to step over the error, the print job continues.
I tried installing VB at work (just in case files were corrupted on my PC) and working on my project there, as well as building a simple browser from scratch. The same thing happens in each instance - the runtime error persists.
Does anyone have any tips for using the ExecWB method to print from the MS Browser Control? Do I need to define a printer? Define variables, etc?
Please help
Clunietp
Jan 31st, 2000, 10:25 AM
If anyone cares, here is the documentation for the webbrowser control:
http://msdn.microsoft.com/workshop/browser/WebBrowser/RefList_VB.asp
bmoffatt
Feb 1st, 2000, 01:23 PM
Discovered the problem...I was trying to call the ExecWB method from the Main form in an MDI project. Once I put the menu bar on the browser form and called ExecWB from there, all was well. Thanks anyway.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.