|
-
Jan 28th, 2000, 02:47 PM
#1
Thread Starter
New Member
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?
-
Jan 28th, 2000, 03:08 PM
#2
Use the WebBrowser's ExecWB Method with the OLECMDID_PRINT Constant, i.e.
Code:
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
[email protected]
[email protected]
-
Jan 29th, 2000, 06:02 AM
#3
Thread Starter
New Member
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?
-
Jan 29th, 2000, 06:51 AM
#4
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
[email protected]
[email protected]
-
Jan 29th, 2000, 02:40 PM
#5
Thread Starter
New Member
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?
-
Jan 31st, 2000, 09:43 AM
#6
Thread Starter
New Member
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
-
Jan 31st, 2000, 11:25 AM
#7
Guru
If anyone cares, here is the documentation for the webbrowser control:
http://msdn.microsoft.com/workshop/b...RefList_VB.asp
-
Feb 1st, 2000, 02:23 PM
#8
Thread Starter
New Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|