HOWTO: Change Print Settings for Internet Explorer and WebBrowser Control Programmatically

ID: Q236777


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5


SUMMARY

This article explains how to set page margins, and header and footer information for printing from Internet Explorer and the WebBrowser control programmatically.


MORE INFORMATION

Users could easily change page margins, and header and footer settings using the Internet Explorer User Interface; however, there are no methods under Internet Explorer or the WebBrowser control to change these settings programmatically.

It is not possible to use the ExecWB command to set page margins, and the header or footer. These values are stored in the registry.

There might be a need to change the print settings of Internet Explorer or the WebBrowser control programatically. The only settings that can be changed are page margins, and header and footer information. There is no supported way to change other settings like page orientation or printer.
WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).


This is how Microsoft Internet Explorer accesses the printing settings:

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 createc 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 0.75 for margins,"&w&bPage &p of &P" for header and "&u&b&d" for footer.

The developer could alter the above registry entries for the printing settings accordingly.
Please note that these values are system-wide and affect all instances of the WebBrowser control and Internet Explorer for the current user.


REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

Q145679 HOWTO: Use the Registry API to Save and Retrieve Setting
Q156732 HOWTO: Print from the Microsoft WebBrowser Control
Q176400 HOWTO: Print the WebBrowser Control
Q188271 HOWTO: Print Contents of the Web Browser Control From VB
For more information, please see the MSDN Web Workshop:
http://msdn.microsoft.com/workshop/default.asp

Additional query words: Print WebBrowser header footer margins orientation

Keywords : kbAutomation kbIE400 kbIE401 kbPrinting kbWebBrowser kbIE401sp1 kbIE401sp2 kbGrpInet kbIE500 kbDSupport kbIEFAQ
Version : WINDOWS:4.0,4.01,4.01 SP1,4.01 SP2,5
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 27, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.