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
Solved

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

Posted on 2004-09-07
6
303 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
  • 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 25 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 25 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

840 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