473,395 Members | 1,972 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,395 software developers and data experts.

Print pdf from Internet Explorer using VB .NET

Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
'For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If
Mar 8 '06 #1
11 11557
Wendy wrote:
Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
'For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If


Why not host the page inside vb.net instead of launching IE? Then you
can print it yourself.

Chris
Mar 8 '06 #2
Hi Chris,

Sorry, but this is the only way that I know. Would you please tell me, at
least in general terms, how to accomplish what you suggest?

Thank you so much,

Wendy

"Chris" wrote:
Wendy wrote:
Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
'For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If


Why not host the page inside vb.net instead of launching IE? Then you
can print it yourself.

Chris

Mar 9 '06 #3

"Wendy" <We***@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs.


Isn't that because you need to use the pdf printing function and not the IE
printing function? Perhaps you need to find a way to send that message to
the pdf display addon.

Mar 9 '06 #4
Your idea makes sense to me, but I don't know where to begin. Can you
suggest anything?

Thank you.

"Homer J Simpson" wrote:

"Wendy" <We***@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs.


Isn't that because you need to use the pdf printing function and not the IE
printing function? Perhaps you need to find a way to send that message to
the pdf display addon.

Mar 9 '06 #5

"Wendy" <We***@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
Your idea makes sense to me, but I don't know where to begin. Can you
suggest anything?


I would explore to see if you can find a way to link to the Adobe software.
Try add a reference, COM, and look for Adobe stuff.

You could also use

SendKeys.Send("^P")

from your program but it's not always reliable and you may need to figure
out how to activate the webrowser app first.

Mar 9 '06 #6
Hi Wendy,

A little example,

Open a new windows application project

In the toolbox rightclick and select add/Remove items

In the customize toolbox select Com and in that Microsoft Webbrowser (This
with 1.1 in 2.0 it is already in the toolbox)

When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxWebBrowser1.Navigate2("www.google.com")
End Sub

Don't instance in 1.1 the webbrowser in code there is a lot placed in the
RESX file with that method.

I hope this helps a little bit?

Cor

"Wendy" <We***@discussions.microsoft.com> schreef in bericht
news:D7**********************************@microsof t.com...
Hi Chris,

Sorry, but this is the only way that I know. Would you please tell me, at
least in general terms, how to accomplish what you suggest?

Thank you so much,

Wendy

"Chris" wrote:
Wendy wrote:
> Hello,
>
> I have a program that does the following:
> When a user clicks on a row in a VB.NET datagrid, it will open a web
> page in
> Internet Explorer (that corresponds to that item in the selected row in
> the
> datagrid). It will automatically print that web page, and then it will
> close
> the Internet Explorer window. I have code that works perfectly when a
> regular web page is opened, however when a pdf web page is opened the
> printing never occurs. Any help would be greatly appreciated. The
> reason
> for the datagrid is that ultimately the user should be able to select
> many
> rows and have all the web pages print without any user intervention.
> Thank
> you! Mrs_Mcse
>
> My VB.NET code is:
>
> If DataGrid1.IsSelected(0) = True Then
>
> Dim selectedItem As Object
> selectedItem = DataGrid1.Item(0, 4)
> 'For testing purposes, just use the first row in the
> datagrid
> and use column 4 that contains a web url
> Dim cellValue As String
> cellValue = selectedItem
>
> Dim Explorer As SHDocVw.InternetExplorer
> Explorer = New SHDocVw.InternetExplorer
> Explorer.Visible = True
> Explorer.Navigate(cellValue)
> Do
>
> Loop Until Explorer.Busy = False
>
> Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
> SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)
>
> End If


Why not host the page inside vb.net instead of launching IE? Then you
can print it yourself.

Chris

Mar 9 '06 #7

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.


But that still won't activate the pdf viewer inside IE and make it print.
That's the tricky part.

Mar 9 '06 #8
Homer,
But that still won't activate the pdf viewer inside IE and make it print.
That's the tricky part.

But that was not the question from Wendy I was answered.

In here reply to Chris she asked how to create an inbuild webbrowswer.

So please read first before you write.

Cor
Mar 9 '06 #9
Homer J Simpson wrote:
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...

When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.

But that still won't activate the pdf viewer inside IE and make it print.
That's the tricky part.


The system should detect that a PDF has been asked for and handle that
seperate from a web page.

Chris
Mar 9 '06 #10

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
So please read first before you write.


You first.

Mar 10 '06 #11
hi
actually i want to know that can i open the same vb.net application
means windows application in the internet explorer?
if yes then say me how ?
i have urgent need for this answer .

Wendy wrote:
Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
'For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If


Apr 7 '06 #12

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

Similar topics

1
by: Ronen | last post by:
Hi, Does anyone experienced memory leak in Iexplore.exe when use treeview (MS IE Controls? I'm have tested this with a simple web page with a few tree nodes generated on the server. Then I...
2
by: Ofer Lavi | last post by:
Hi, I am trying to build an activeX that, if missing, will be downloaded and setup automatically on the client's browser (internet explorer). Using VB6, it was easy, using the <Object> tag,...
0
by: Friskusen | last post by:
I have a control library written in Vb.Net and now i am very eager to use the controls with Internet explorer, using the object tag, something like this: <object id="MyButton1"...
2
by: v.srikhar | last post by:
hi I had some problem .Ii had to open the ms word file in IE itself not outside using jsp or java can any one solve it out. thanks
1
by: Andy Chen | last post by:
Some web sites offer contents in multiple languanges, we can do it manully by click on IE Options - Internet options. My questions is how to change it by C# code. Thanks! Andy
0
by: gaurav2325 | last post by:
Hi, I would like to create a plugin for internet explorer to run my document. My document contains specific type of data, so that, I want whenever the user open that document (that is word...
0
by: nehacredo | last post by:
hi alll.. i wanna display a word file content in a browser..how can i do that..i hav done one coding in that i can display the contents...but with contents some symbols also coming... anyone pls...
0
by: Ajay Zambad | last post by:
Hi, i am able to connect internet explorer using Excel macro but not getting that how to connect the options like (Upload, Brows, insert) into IE using macro. Regards, Ajay
14
by: loudey | last post by:
I have a VBA program that automates an internet explorer process the whole code works except one piece. when I try using this code, Dim IEapp As Object Dim IEdoc As Object Set IEapp = New...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.