Results 1 to 8 of 8

Thread: Printing Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    5

    Post

    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?

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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]


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    5

    Post

    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?

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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]


  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    5

    Post

    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?

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    5

    Post

    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

  7. #7
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    If anyone cares, here is the documentation for the webbrowser control:
    http://msdn.microsoft.com/workshop/b...RefList_VB.asp

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    5

    Post

    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
  •  



Click Here to Expand Forum to Full Width