Skip to content

Planet-Source-Code/philip-leitch-print-html-from-visual-basic__1-37377

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Print HTML from Visual Basic

Description

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

More Info

Submitted On
By Philip Leitch
Level Beginner
User Rating 4.3 (17 globes from 4 users)
Compatibility VB 5.0, VB 6.0
Category Internet/ HTML
World Visual Basic
Archive File

Source 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:\temp\Request.htm")

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published