Solved

Hiding Print Properties dialog

Posted on 2002-05-30
5
384 Views
Last Modified: 2007-11-27
Hi,

I am trying to print an HTML page I built in a HTMLDocument object. However, this print must happen in the background, but the print properties dialog is always popping up.

Is there any way of getting rid of this dialog, and just letting the print go through as is with the default print properties?

I have tried:
mvarDocument.execCommand "Print", OLECMDEXECOPT_DONTPROMPTUSER, 0

and even:

Dim s As Variant
s = 0
mvarDocument.execCommand "Print", OLECMDEXECOPT_DONTPROMPTUSER, s

with no success at all, depsite what the MSDN says.

Does anyody have any ideas regarding this one?

Many thankx in advance,
Mark Hewitt
0
Comment
Question by:mh2
[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
5 Comments
 
LVL 9

Expert Comment

by:Nitin Sontakke
ID: 7044016
I am not too sure the object model you have mentioned. However, i have successfully done what you are trying to achieve using WebBrowser control (IE 6).

Here is the code i have used:

wbPrintHTML.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

Hope it helps.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7048293
As long as i did read from MSDN, if you use IE version >5, it is not possible since IE overrides OLECMDEXECOPT_DONTPROMPTUSER parameter, but NitinSontakke saids the opossite :(
0
 
LVL 3

Author Comment

by:mh2
ID: 7055588
Hi,

Well, I know it can be done from a WebBrowser control as NitinSontakke says, despite the MSDN. The documentation seems a bit confusing on this matter.

I did alot of experimentation, and no success in a real sense. I did manage to create a hacked solution that works for me now. Not great I guess, but it'll do for the milestone demonstation on Friday.

What I did was create a WebBrowser control dynamically in the background, and use it to feed the print through. Talk about a hack hey! But it works for now.

Heres my code if you are interested...

'-------------------------------------------------

Public Function SendToPrinter() As Integer
   
    Dim tmpObject As Object
    Dim ptBrowser As WebBrowser  ' Object
   
    Set tmpObject = Forms(0).Controls.Add("Shell.Explorer.2", "WB1")
   
    ' for IE 6.x the browser control is wrapped in some kind of a outer wrapper
    ' so we need to access the inner object to get the browser, and set the outer to visible
    If TypeOf tmpObject Is WebBrowser Then
        Set ptBrowser = tmpObject
    Else
        Set ptBrowser = tmpObject.object
    End If
   
    ptBrowser.RegisterAsDropTarget = True
    ShowInBrowser ptBrowser

    tmpObject.Visible = True
    ptBrowser.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, "", ""
    tmpObject.Visible = False
   
    Forms(0).Controls.Remove "WB1"

    SendToPrinter = 1
End Function

'-------------------------------------------------------

One thing I found, depending on your system, MS sometimes wraps the WebBrowse control returned in some funny outer wrapper. I thought it was just IE 6.x, but then I found a sstem with an identical IE version to mine, 5.5 something, and it also had this wrapper!

Thankx,
Mark
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851293
mh2, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.
    *** mh2 -- I used that technique/hack in C++ Did you ever find a better way?

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7912884
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

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!

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 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