Search Tools Links Login

Print HTML from Visual Basic


Visual Basic 6, or VB Classic

The purpose of this article is to explain how to get the WebBrowser to print (i.e. there is no standard print method)

Original Author: Philip Leitch

Code

I was creating a form to be printed by HTML, then, after creating the form, realised that I didn't know how to print the HTML. I looked into it further and found some obscure way in MSDN and some message boards to set focus (through Windows API) to my HTML WebBrowser control and send it a Control P key. The problem is that that only brings up a print dialogue. I didn't even want to show the HTML form, let alone ask the user to select which printer. I searched further and found a workable solution. Here it is:




frmHTML.WebBrowser1.Navigate("C: empRequest.htm")


frmHTML.WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0


About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 114 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.