Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing Landscape w/web browser control

1,795 views
Skip to first unread message

Jeff Lieder

unread,
Jul 24, 2001, 2:57:25 PM7/24/01
to
Is there any way to get the web browser control to print in landscape
WITHOUT having to prompt the user?

Thank You,

Jeff


Tore

unread,
Jul 26, 2001, 1:04:45 PM7/26/01
to
Not directly, but there are a couple of workarounds. Do a (boolean) search
of MSDN with 'Landscape and "browser control"' as the search criteria. That
will provide explanations and samples.

HTH,
Tore.

"Jeff Lieder" <Noe...@hotmail.com> wrote in message
news:eovHDKHFBHA.1556@tkmsftngp02...

Billy Joe

unread,
Jul 27, 2001, 3:16:12 AM7/27/01
to
Tore,
I tried 'Landscape and "browser control"' (with/without the single quotes)
and got zero topics found. Then tried 'Landscape AND (browser near
control)' also (with/without the single quotes) to find some good material.
Am I doing something wrong in my MSDN searches? Is there a setting I may
have overlooked somewhere?
I had Entire Collection selected and no refinement checkboxes checked at the
time.
TIA,
Billy Joe


"Tore" <TBos...@teamia.com> wrote in message
news:ucmmtTfFBHA.1484@tkmsftngp05...

Steven Allen

unread,
Jul 26, 2001, 7:44:46 PM7/26/01
to
The orientation for the web browser is set and read in the registry at the
location
Software\Microsoft\Internet Explorer\PageSetup
the value is stored in "orientation"

the value 1 = portrait
the value 2 = landscape

try using the following function:
'------------------
Public Function setOrientation(ByVal theOrientation As String) As String
' changes the printers orientation and returns the old value.
Dim retVal
setOrientation = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "orientation")
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"orientation", theOrientation)
End Function
'------------------

'Example of use
Dim originalOrientation As String

'Set the oreintation to landscape
originalOrientation = modPrinter.setOrientation("2")

'Print the document
webbrowser1.SetFocus
webbrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0

'Change the orientation back to the original orientation
originalOrientation = modPrinter.setOrientation(printDefaultOrientation)

Here are some other functions that may be of use to you:
HTH Steven Allen (dybrn)
'-----------------
'Found at http://support.microsoft.com/support/kb/articles/Q236/7/77.ASP

'For Page Margins, Microsoft Internet Explorer first
'tries to get the values from this registry key:
'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup

'If there is no such a key, Internet Explorer create
'this key by copying the values from the following:
'HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\PageSetup

'If there is no such key, default values are provided.

'For the Header and Footer, the values are picked up from the following:
'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup

'If there is no such key, default values are provided.
'The defaults are
' Margins: 0.75
' Header: &w&bPage &p of &P
' Footer: &u&b&d

'For the Internet Explorer default printer, default values are provided
from:
'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\printer

Public Type printerMargins
margin_left As String
margin_right As String
margin_top As String
margin_bottom As String
End Type

Public Function setOrientation(ByVal theOrientation As String) As String
' changes the printers orientation and returns the old value.
Dim retVal
setOrientation = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "orientation")
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"orientation", theOrientation)
End Function

Public Function setHeader(ByVal theHeader As String) As String
' changes the header and returns the old value.
Dim retVal
setHeader = RegRead("Software\Microsoft\Internet Explorer\PageSetup",
"header")
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"header", theHeader)
End Function

Public Function setFooter(ByVal theFooter As String) As String
' changes the Footer and returns the old value.
Dim retVal
setFooter = RegRead("Software\Microsoft\Internet Explorer\PageSetup",
"Footer")
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"Footer", theFooter)
End Function

Public Function SetDuplex(ByVal theValue As String) As String
' Turns on or off the duplexer depending on "theValue".
Dim retVal
Dim newValue As String

If theValue = "2" Then
newValue = "2" 'ON
Else
newValue = "1" 'OFF
End If
SetDuplex = RegRead("Software\Microsoft\Internet Explorer\PageSetup",
"duplex")
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"duplex", newValue)
End Function

Public Function SetMargins(thePrinterMargins As printerMargins) As
printerMargins
Dim retVal

SetMargins.margin_left = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "margin_left")
SetMargins.margin_right = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "margin_right")
SetMargins.margin_top = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "margin_top")
SetMargins.margin_bottom = RegRead("Software\Microsoft\Internet
Explorer\PageSetup", "margin_bottom")

retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"margin_left", thePrinterMargins.margin_left)
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"margin_right", thePrinterMargins.margin_right)
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"margin_top", thePrinterMargins.margin_top)
retVal = RegWrite("Software\Microsoft\Internet Explorer\PageSetup",
"margin_bottom", thePrinterMargins.margin_bottom)

End Function


"Tore" <TBos...@teamia.com> wrote in message
news:ucmmtTfFBHA.1484@tkmsftngp05...

Tore

unread,
Jul 27, 2001, 10:25:43 AM7/27/01
to
I have the full January 2001 MSDN library installed (a little lax on
updates...), and my search for 'Landscape and "browser control"' (no single
quotes, but with the double quotes), gives me one match (I have turned of
all the options - Search previous results (no), Match similar words (no),
and Search titles only (no)):

Printing with the Internet Explorer WebBrowser Control
Dave Templin
Microsoft Corporation
January 2000

This article is part of the Web Workshop.

"How can I specify the target printer or set Landscape mode and other print
attributes? The WebBrowser does not expose a way to programmatically specify
a target printer or any other print attributes; therefore, there is no
directly-supported way of programmatically defining these settings from
script or from an application hosting the WebBrowser control.
There are two workarounds. The first and most straightforward approach is to
hook the Print dialog box and send a message to appropriate window control
(that is, send a WM_SETTEXT message to the Printer combo box to select the
desired printer). The other approach is to temporarily change the
application default printer. Both of these approaches are discussed further
in the Printing Workarounds section."

Hopefully, the above gives you enough to find the article.

HTH,
Tore.


"Billy Joe" <bjb...@netzero.BillyJoe.net> wrote in message
news:u1D33cgFBHA.1916@tkmsftngp02...

Jeff Lieder

unread,
Jul 27, 2001, 3:20:47 PM7/27/01
to
Thanks for the replies............


"Jeff Lieder" <Noe...@hotmail.com> wrote in message
news:eovHDKHFBHA.1556@tkmsftngp02...

Billy Joe

unread,
Jul 28, 2001, 4:11:35 PM7/28/01
to
Looks like there is NO Web Workshop in July, 2001 issue. That explains my
search failure.
Thanks for replying.
Billy Joe

"Tore" <TBos...@teamia.com> wrote in message

news:#YsdffqFBHA.1604@tkmsftngp05...


I have the full January 2001 MSDN library installed (a little lax on

<snip>


Printing with the Internet Explorer WebBrowser Control
Dave Templin
Microsoft Corporation
January 2000

This article is part of the Web Workshop.

<snip>


0 new messages