Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Giving the focus to the webbrowser Document for printing

Posted on 2004-05-03
7
Medium Priority
?
271 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:kedarpd
  • 3
  • 2
7 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 10975323
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
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 10975327
Printing on the standard printer of the system:
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
0
 

Author Comment

by:kedarpd
ID: 10975639
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
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 1000 total points
ID: 10975671
Try this:
'set a reference to microsoft word x object library
option explicit

dim wdoc as word.document
' in Document_complete event of webbrowser paste this:
if (pdisp is webbrowser1.object)
   set wdoc= webbrowser1.document
   'example of how to access Word DOM:
   wdoc.PrintPreview
   ' and so on...
end if

Hope it helps
0
 

Author Comment

by:kedarpd
ID: 10975778
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
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question