Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

734 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