How to use the WebBrowser control to open Office documents in Visual C# 2005 or in Visual C# .NET
http://support.microsoft.com/?scid=kb%3Ben-us%3B304662&x=11&y=11
According to this link, we should edit the registry key first if we use IE 7 and onword.
Added the .reg file as follow.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.8] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.RTF.8] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.12] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.DocumentMacroEnabled.12] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.8] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetMacroEnabled.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetBinaryMacroEnabled.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.8] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.ShowMacroEnabled.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.8] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShowMacroEnabled.12] "BrowserFlags"=dword:800000A0
Please do backup the registry keys before changing.
*** It still works on office 2010. The webbrowser control can be the control in the Access form.
However, it offers us a way to open office document in a winform. Somebody wants to show blank .doc document in a winform without showing the toolbar. Maybe more efforts should be put into the following code line:
Object refmissing = System.Reflection.Missing.Value; axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,ref refmissing , ref refmissing);