Solved

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

Posted on 1998-07-20
4
136 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
  • 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

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now