473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Printing WebPages from VB.net

I have a couple pages on our intranet that I want to print on a
regular basis. The conent is dynamic, and so I want to take
snapshots, and send these jobs directly to a printer on the network.

Has anyone done this before? I'm looking for some sample code.

Thanks,

Peter
Nov 20 '05 #1
5 1850
I have code that achieves this in VB6 if you wish to take a look at it - I
will dig it out. I did ave problems getting this to work due to the
Microsoft security patches, but some kind soul e-mailed me the solution
months after my original post. It may be a few hours before I get the chance
to search for the code.

Best wishes

Paul Bromley

"Peter" <pe***@mclinn.com> wrote in message
news:dc*************************@posting.google.co m...
I have a couple pages on our intranet that I want to print on a
regular basis. The conent is dynamic, and so I want to take
snapshots, and send these jobs directly to a printer on the network.

Has anyone done this before? I'm looking for some sample code.

Thanks,

Peter

Nov 20 '05 #2
* pe***@mclinn.com (Peter) scripsit:
I have a couple pages on our intranet that I want to print on a
regular basis. The conent is dynamic, and so I want to take
snapshots, and send these jobs directly to a printer on the network.


2 solutions:

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.htm"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
///

- or -

<URL:http://groups.google.de/groups?selm=%23695K4B7CHA.548%40TK2MSFTNGP11.phx.g bl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi Peter,

Hope this helps. It took me quite a time to get the answer initially, and
then my code stopped working after 5.5 of Internet Explorer, but thankfully
due to some kind soul who e-mailed me a couple of months after I put out a
query, the problem was resolved - by sending 0s in the parmaters rather than
null strings as initially recommended by the Microsoft dcoumentation.

I have quickly tried the coe in VB.Net and it seems to work for me.

Best wishes

Paul Bromley

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim sPrintEm As Integer = 1
Dim eQuery As SHDocVw.OLECMDF
eQuery = AxWebBrowser1.QueryStatusWB(SHDocVw.OLECMDID.OLECM DID_PRINT)
If Err.Number = 0 Then
If eQuery And SHDocVw.OLECMDF.OLECMDF_ENABLED Then
Select Case sPrintEm
Case "1"
AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, 0, 0)
Case "2"
AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER , 0, 0)
End Select
Else
MsgBox("The Print command is currently disabled.")
End If
End If
End Sub
"Peter" <pe***@mclinn.com> wrote in message
news:dc*************************@posting.google.co m...
I have a couple pages on our intranet that I want to print on a
regular basis. The conent is dynamic, and so I want to take
snapshots, and send these jobs directly to a printer on the network.

Has anyone done this before? I'm looking for some sample code.

Thanks,

Peter

Nov 20 '05 #4
Both of these solutions worked great. For us less technical gurus, I
had to 1. Add Reference - Microsoft.mshtml
2. Open a form and add in a com object named: Microsoft Web Browser

The rest of the code worked sweet! Thanks!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AxWebBrowser1.Navigate("http://www.google.com")

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim sPrintEm As Integer = 1
Dim eQuery As SHDocVw.OLECMDF
eQuery = AxWebBrowser1.QueryStatusWB(SHDocVw.OLECMDID.OLECM DID_PRINT)
If Err.Number = 0 Then
If eQuery And SHDocVw.OLECMDF.OLECMDF_ENABLED Then
Select Case sPrintEm
Case "1"

AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, 0, 0)
Case "2"

AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER , 0, 0)
End Select
Else
MsgBox("The Print command is currently disabled.")
End If
End If
End Sub

The other code printed anything locally without issue! You guys rock!
Thanks!
Nov 20 '05 #5
Sorry Peter, I should have mentioned adding the reference and the
web-browser control. I think that I had assumed that you were navigating to
the Intranet page with a Web browser anyway, hence you had the control in
your application anyway. Glad I can help - I have had a lot of help myself
here in the past and am by no means an expert.

Best wishes

Paul Bromley

"Peter" <pe***@mclinn.com> wrote in message
news:dc**************************@posting.google.c om...
Both of these solutions worked great. For us less technical gurus, I
had to 1. Add Reference - Microsoft.mshtml
2. Open a form and add in a com object named: Microsoft Web Browser

The rest of the code worked sweet! Thanks!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AxWebBrowser1.Navigate("http://www.google.com")

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim sPrintEm As Integer = 1
Dim eQuery As SHDocVw.OLECMDF
eQuery = AxWebBrowser1.QueryStatusWB(SHDocVw.OLECMDID.OLECM DID_PRINT) If Err.Number = 0 Then
If eQuery And SHDocVw.OLECMDF.OLECMDF_ENABLED Then
Select Case sPrintEm
Case "1"

AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, 0, 0)
Case "2"

AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER , 0, 0)
End Select
Else
MsgBox("The Print command is currently disabled.")
End If
End If
End Sub

The other code printed anything locally without issue! You guys rock!
Thanks!

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Robbins | last post by:
I need to create some reports for printing from my database. From everything I can find using Google, there doesn't seem to be any ways to override the default header and footer. Is this still...
16
by: Geoff Cox | last post by:
Hello, I publish some web pages using large fonts and would like to give the user the opportunity to print the pages using a smaller font. I believe that this is possible using different style...
3
by: Trent | last post by:
Hello, I am creating a stylesheet for printing out some webpages. I would like the printed pages to NOT display buttons. However, text fields should be printed. Therefore, the following code...
7
by: dow | last post by:
I'm looking for ideas or how to make webpages for members. I want a member log in and view their profiles and check boxes stating that they have completed listed instructions and waiting for the...
5
by: Michael Landberg | last post by:
Hi this may be a stupid question, but anyway! I have created a website with a few pages. I have noticed that when I change the IE browser text size ( through the view menu -> text size) to...
0
by: xmail123 | last post by:
I have written the following simple C# project in Visual studio. I am trying to see how the XML documenting works. I click Tools, Build Comment WebPages… then just click OK in the Build Comment...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
3
by: scorpion53061 | last post by:
Hi I am actually a vb.net windows developer using code to write a web page. I have a loop that writes rows to the web page. What I would like to do is: 1. Every five tables force a page break ...
4
by: Andy G | last post by:
I have web articles that are in HTML and consist of 4 or 5 pages b/c of the amount of content. Ideally, I would like to leave the text separate into multiple pages for web viewing but when someone...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.