Solved

Hiding Print Properties dialog

Posted on 2002-05-30
5
385 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 55
Added a column screws up code 5 78
Assign a value in Excel V-Basic 3 38
VB6 Enviroment 3 35
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

734 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