Select the product you need help with
How to use the WebBrowser control in Visual Basic to open an Office documentArticle ID: 304643 - View products that this article applies to. This article was previously published under Q304643
For a Microsoft Visual C# 2005 and Microsoft Visual C# .NET version of this article, see 304662
(http://support.microsoft.com/kb/304662/
)
.
On This PageSUMMARY You may want to display, or embed, a Microsoft Office document
directly on a Microsoft Visual Basic form. Microsoft Visual Basic 2005 and Visual Basic .NET do not provide an OLE control that lets you embed an
Office document in a form. If you want to embed an existing document and open
it as an in-place ActiveX document object within a Visual Basic form, a
potential solution for you is to use the WebBrowser control. This article demonstrates how to browse to an existing Office document and display it in a Visual Basic form by using the WebBrowser control. MORE INFORMATION ActiveX documents are embeddable OLE objects that behave
more like ActiveX controls than traditional OLE objects. Unlike a traditional
embedded object, an ActiveX document is not designed to be a contained object
in a larger document. Instead, it is considered in itself a complete document
that is merely being viewed (such as with Microsoft Internet Explorer) or
collected in a single resource with other documents (such as a Microsoft
Office Binder file). An ActiveX document that is hosted in the WebBrowser control is always active; therefore, unlike traditional OLE
embedded objects, there is no sense of in-place activation. While Microsoft Visual Basic .NET and Visual Basic 2005 do not currently support hosting ActiveX documents directly, you may use the WebBrowser control for this purpose. The WebBrowser control (Shdocvw.dll) is a part of Internet Explorer and can only be used on systems that have Internet Explorer installed. Creating a Visual Basic application that opens Office documentsTo create a Visual Basic application that opens Office documents, follow these steps:
Considerations when you use the WebBrowser controlYou should consider the following when you use the WebBrowser control:
Considerations when you use the WebBrowser control together with a 2007 Microsoft Office programBy default, the 2007 Office programs do not open Office documents in the Web browser. This behavior also affects the WebBrowser control. We recommended that you use a custom ActiveX document container instead of the WebBrowser control when you develop applications that open 2007 Office documents. For more information about custom ActiveX document containers, click the following article number to view the article in the Microsoft Knowledge Base:311765 For existing applications that require backward compatibility with the WebBrowser control, you can modify the registry to configure Internet Explorer. You can use this method to configure Internet Explorer to open 2007 Office documents in the Web browser.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/311765/
)
Visual C++ ActiveX control for hosting Office documents in Visual Basic or HTML
927009 Note If you modify the registry by using the method that is mentioned in Knowledge Base article 927009, the changes affect the WebBrowser control that you use in the application. The changes also affect all instances of Internet Explorer. Additionally, this method may not work for any future versions of the Microsoft Office suites. Therefore, we recommend that you use this method only for compatibility with a existing application.
(http://support.microsoft.com/kb/927009/
)
A new window opens when you try to view a 2007 Microsoft Office program document in Windows Internet Explorer 7
REFERENCES
For more information about how to use the WebBrowser control, click the following article numbers to view the articles in the Microsoft Knowledge Base:
304562
(http://support.microsoft.com/kb/304562/
)
Visual Studio 2005 and Visual Studio .NET do not provide an OLE container control for Windows Forms
243058
(http://support.microsoft.com/kb/243058/
)
How to use the WebBrowser control to open an Office document
162719
(http://support.microsoft.com/kb/162719/
)
How to use the WebBrowser control from Visual Basic 5.0
202476
(http://support.microsoft.com/kb/202476/
)
BUG: Cannot edit Word document in OLE or WebBrowser control
188271
(http://support.microsoft.com/kb/188271/
)
How to print contents of the WebBrowser control from VB
191692
(http://support.microsoft.com/kb/191692/
)
Shdocvw.dll is not included in PDW setup package
238313
(http://support.microsoft.com/kb/238313/
)
Accessing the Internet Explorer Document Object Model from Visual Basic
927009
(http://support.microsoft.com/kb/927009/
)
A new window opens when you try to view a 2007 Microsoft Office program document in Windows Internet Explorer 7
PropertiesArticle ID: 304643 - Last Review: September 16, 2007 - Revision: 8.1 APPLIES TO
| Article Translations
|


Back to the top








