Thomas,
I haven't had to print from the IE window itself nor have I had to specify a
printer other than the Default Printer; however, I did some searching and it
appears that I came across some code that may help you.
The ExecWB Method (see the msdn link below, which has separate links to the
constants) will execute your print command. Application.ActivePrinter will
allow you to specify the desired printer. There is code below which uses the
previously posted GetIE function. Obviously, you'll need to change the code
below to reflect the appropriate URL, print constants for ExecWB, and printer
name.
Note: It appears that the name of the printer has a ":" at the end of the
text, e.g. the printer dialog shows my printer as HPLJ4100 but
Application.ActivePrinter reveals "HPLJ4100 on Ne04:". Maybe you are more
familiar than I am about printers -- I know that printers print and that's
about it -- so if my next comment is not new information, please ignore it.
One way to get the correct printer name would be to change your default
printer and then do one of the following:
(1) in the Immediate Window (View | Immediate Window), type
?Application.ActivePrinter [and then hit <Enter>]
(2) run a sub with this syntax
Debug.Print Applcation.ActivePrinter [which will print to the Immediate
Window].
http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx
I hope this helps.
Best,
Matt
Sub PrintIEWindow()
Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Dim objIE As Object
Dim strCurrentPrinter As String
Dim strDesiredPrinter As String
'get the current printer, so that it can be reset
' when the print command is finished
strCurrentPrinter = Application.ActivePrinter '"text name:"
'specify the printer to print to
strDesiredPrinter = "xxx:"
'set the specified printer
Application.ActivePrinter = strDesiredPrinter
'get the IE window
Set objIE = GetIE("
http://www.google.com/")
'print the IE window
objIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
'change the printer back
Application.ActivePrinter = strCurrentPrinter
End Sub