?
Solved

50 Easy points!  Is it possible to print with WebBrowser1.Visible set to False?

Posted on 2004-09-07
6
Medium Priority
?
316 Views
Last Modified: 2013-12-25
Here's my code:

Private Sub Form_Load()
     WebBrowser1.Navigate "www.cnn.com"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If WebBrowser1.ReadyState = READYSTATE_COMPLETE Then
      WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
    End If
End Sub

Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
    Me.Caption = Text
End Sub

Is it possible for this code to work if the WebBrowser1.Visible is set to False?
0
Comment
Question by:shaolinfunk
[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
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:coopzz
ID: 12003074
yer should do

I do something similar things in vb.net and vb6 eg: a notification service that prints web pages  to printers in a windows service

actually if anyone knows of an object that can print web pages with specified printer without using this internet controls would be a great find
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 100 total points
ID: 12003512
Did you test it ? Perhaps you need another event. Can you give this a try
Private Sub Form_Load()
     WebBrowser1.Navigate "www.cnn.com"
End Sub

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    WebBrowser1.Visible = True
    WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
    WebBrowser1.Visible = False
End Sub

Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
    Me.Caption = Text
End Sub
0
 
LVL 11

Expert Comment

by:coopzz
ID: 12003606
try that event it worked perfectly

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    WebBrowser1.Visible = True
    WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, Null, Null
    WebBrowser1.Visible = False
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:shaolinfunk
ID: 12011866
actually.  what i meant by my question was having it set to false ALL the time.  is it possible to do that and still print?  that way, the user doesn't know that there was a webbrowser control there.
0
 
LVL 11

Assisted Solution

by:coopzz
coopzz earned 100 total points
ID: 12012137
well why don't you just use the other solution you got.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_21108534.html

that should work a hell of a lot better.

if you don't want a user to see the form, do a microsoft hack and place the form in a really obscure spot without putting it in the system tray.
top = -1000
left = -1000
showintaskbar = false

cause it looks like with the control it needs to be visible in vb to print Sorry.
but Like I said the other way I've used and works. try starting from scratch again.


0
 
LVL 1

Author Comment

by:shaolinfunk
ID: 12025678
"cause it looks like with the control it needs to be visible in vb to print Sorry."
that's what i wanted to make sure of.  thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 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