Solved

Giving the focus to the webbrowser Document for printing

Posted on 2004-05-03
7
256 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 250 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article will show, step by step, how to integrate R code into a R Sweave document
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now