Solved

hi@@ Question:How to print web page in VB?

Posted on 1998-07-20
4
143 Views
Last Modified: 2010-05-03
Hi guys! Hope u can help me out here! :) I am using a web browser control in VB5.0
and I want to implement a print button to print the contents of the web browser control....
I saw in the history a example which goes .. WebBrowser1.ExecWB something...
but this control that I am using doesn't support this method/operation.
Maybe it is a different (earlier) version of the webbrowser control?
An example from u experts would be nice .. Thanks !!!

David Chong
0
Comment
Question by:Haho
[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
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
wford earned 70 total points
ID: 1466292
OK, here is the comand

Private Sub Command1_Click()
        WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT
End Sub

the trick is you need the latest shdocvw.dll which is at least:

18.11.97 (version 4.72.2106.7). which comes with IE4, so you will need a copy

You can find all the help you need at:

http://www.microsoft.com/msdn/sdk/inetsdk/help/itt/IEProg/WB/Objects/WebBrowser.htm#WebBrowser

This is a synopsis of my question (A lot of this came from ClifABB in my question):
http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10061325
0
 
LVL 1

Author Comment

by:Haho
ID: 1466293
Thanks wford , but I have referred to the history example b4 ( using ExecWB)...
but my comp. has decided to use shdocvw.dll from IE3 , and not IE4 so I won't be able to use ExecWB..
is there any other way ( perhaps through more longer/complicated coding ) that allows me to print the web page instead of using the shdocvw.dll from IE4.
The reason is because most of our customers might not have the latest IE version (v4)
BTW, can we package the IE4 shdocvw.dll together with my application?
Is the IE4 shdocvw.dll fully compatible with IE3 shdocvw.dll??
A short example would be appreciated .. thanks!!



0
 
LVL 1

Expert Comment

by:wford
ID: 1466294
Ah, yes we had exactly the same problem,
our original solution was to use the shellexecute function,
this is OK if you only have one form, and do not mind dialog boxes poping up evernow and again(depends on the browser installed).

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

n = ShellExecute(Me.hwnd, "Print", TempFile, "", "", 5)

where, tempfile is a flat file with an Html extention, you also need to check if there is a print command on the computer, for this you need to look in the registery.

the other solution is the one i found too late and which I think is better, there is an OCX called webster pro, at www.homepagesw.com, it costs about $465, and has a couple of print functions in it, it is about a meg in size and you can ship it with your app.
 good luck
0
 
LVL 1

Author Comment

by:Haho
ID: 1466295
Thanks, wford... here are your points.. :)

David Chong
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 8 hours left to enroll

635 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