1. Home
  2. Computing & Technology
  3. Delphi Programming

Opening Office Documents (Word, Excel) in TWebBrowser on Vista and Office 2007
Do NOT open a new window when navigating to Word (Excel) in TWebBrowser on Vista

By Zarko Gajic, About.com

When, in your Delphi application, you are using the TWebBrowser control to open Word (Excel) document for preview and/or print - if your application is running on Vista with Office 2007 installed you might experience weird behaviors.

By default, when you try to navigate to and open a Microsoft Office Word 2007 document, (Excel or PowerPoint) in the TWebBrowser control (embedded IE), the document may not open in the "same window" - instead a new Word 2007 (Excel 2007, PowerPoint 2007) window opens to display the document.

Forcing "Browse in the same IE window"

In Office 2003 the default behavior was to open a document in the same (IE) window - in Office 2007 the default is to open the document in a new/separate window.

In order to get the document open inside the web browser control you will need to alter a few registry entries on the client machine.

Work 2007:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.8]
"BrowserFlags"=dword:80000024

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.12]
"BrowserFlags"=dword:80000024



Excel 2007:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.8]
"BrowserFlags"=dword:80000A00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12]
"BrowserFlags"=dword:80000A00

Of course, you can modify the registry programmatically using Delphi code.

Note that this is a "hack" and this Internet Explorer feature may not exist in future operating systems that are later than Windows Vista.

Delphi tips navigator:
» Custom Drawing of TListView Items - Font, Colors, Graphics
« TreeView Items - Dynamic Context (Popup) Menus in Delphi

More Delphi Programming Quick Tips
Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2008 Tips
  7. Opening Office Documents (Word, Excel) in TWebBrowser on Vista and Office 2007

©2009 About.com, a part of The New York Times Company.

All rights reserved.