Solved

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

Posted on 2004-09-07
6
298 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

786 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