Solved

Giving the focus to the webbrowser Document for printing

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

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 make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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 …
Introduction to Processes

617 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