Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hiding Print Properties dialog

Posted on 2002-05-30
5
Medium Priority
?
400 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 10

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 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…
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…
Suggested Courses

688 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