Link to home
Start Free TrialLog in
Avatar of kedarpd
kedarpd

asked on

Giving the focus to the webbrowser Document for printing

Hi

I want to put the focus on the webbrowser object when the form loads. Webbrowser object contans a word document. When i say print , it takes forever time. If i click on the document and then click on print it prints immediately.If i dont click on the webbrowser control and click on print it takes forever time. please advise.

The code for printing.

Private Sub mnuprint_Click()
    ' dislays the print dialog box and prints
    WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
    Exit Sub
End Sub

This the code for printing the webbrowser contents. Any sugesstions or advise will be appreciated.

Thnkx

Kedar P Deshpande
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Does this speed it up ?

Private Sub mnuprint_Click()
' SET THE FOCUS on the webbrowser
    WebBrowser1.setfocus
    ' dislays the print dialog box and prints
    WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
    Exit Sub
End Sub
Printing on the standard printer of the system:
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
Avatar of kedarpd
kedarpd

ASKER

Hi Dhaest,

Thnx for ur advise , but  even this does not help. Even if i use setfocus method also it does not print.

Any oher idea abt this

Kedar
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kedarpd

ASKER

Hi Dhaest,
That does help.

But i want to acheive the printing functinality at the menu click event . The code that u have given starts printing once the document is loaded. but instead i want to give the user a functinality like menu whic hhe can click and then that starts printing.

Thnx...

Kedar