------------------------------------------------------打開文檔-------------------------------------------------------------------
string strmubanPath = @'d:/muban.doc';//得到模板位置
webBrowser2.Navigate(strmubanPath);//, ref refmissing, ref refmissing, ref refmissing, ref refmissing);
-------------------------------------------------------保存文檔--------------------------------------------------------------------------- 需要添加引用 Interop.Word.dll
object axWebBrowser; //定義web瀏覽器
axWebBrowser = this.webBrowser1.ActiveXInstance;
Word.ApplicationClass word1;
PS:如果webBrowser1不在當(dāng)前選中的窗體中,,或者不在當(dāng)前選項(xiàng)卡中,好像保存無(wú)效,。 ----------------------------------------------------------清空文檔---------------------------------------------------------------
//該方法好像并沒(méi)有真正的釋放Word進(jìn)程,,文件依然被占用,目前還沒(méi)有找到好的解決辦法,。
----------------------------------------------------------在office 2007中打開--------------------------------------------------------------- //如果裝的是office 2007的話,,用webBrowser打開Word文件時(shí),不會(huì)在webBrowser中打開,,而是直接打開了Word程序,,解決辦法是修改注冊(cè)表選項(xiàng),將以下內(nèi)容保存到記事本中,,存為reg格式的文件運(yùn)行即可
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 |
|