Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-07-20
4
Medium Priority
?
145 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 210 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

885 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