Solved

Hiding Print Properties dialog

Posted on 2002-05-30
5
375 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
5 Comments
 
LVL 6

Expert Comment

by:Nitin Sontakke
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now