Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Giving the focus to the webbrowser Document for printing

Posted on 2004-05-03
7
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
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…
Six Sigma Control Plans

722 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