????? C# 2005 ?? Visual C# .NET ??? Office ????????? ?? ????? ?? ??? WebBrowser ???????? ?? ????? ???? ????

???? ?????? ???? ??????
???? ID: 304662 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? ???? ?? Microsoft Visual Basic .NET ??????? ?? ???, ?????304643.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ?? Microsoft Visual C# ??????? ?? ?? Microsoft Office ????????? ??? ?????? ???? ?? ??? ?? ????????? ???? ?? ??? ?? ???? ???? Microsoft Visual C# 2005 ?? Microsoft Visual C# .NET ??????? ?? ?? Office ????????? ??? ?????? ???? ?? ??? ???? ?????? ???? ?? ?? OLE ???????? ?????? ????? ??? ?? ??? ?????? ????????? ?????? ???? ?? ??? ??-????? ActiveX ???????? ??? ???? ???????? ????? C# ??????? ?? ??? ??? ????? ????? ???, ?? ?? ?? ??? ??????? ?????? ?? Microsoft WebBrowser ???????? ?? ????? ???? ?? ????

????????? ???? ?? ?? ???? ?? ???? Office ?? ??? ?????? ????????? ?? ??? ??????? ???? ?? ???? ??? WebBrowser ???????? ?? ????? ?? Visual C# ??????? ?? ???? ????????? ?????

???? ???????

ActiveX ???????? ??? ?? ???? ???????? OLE ???????? ?? ActiveX ???????? ?? ??? ??????? embeddable OLE ???????? ??? ??? ???????? ???????? ????????, ???? ?? ?????? ???? ActiveX ???????? ?? ??????? ???? ?? ??? ???????? ??? ??? ???????? ???? ???? ?? ???? ???? ????, ?? ?? ???? ????? ??? merely ???? ?? ??? ?? ?? ???? ???????? (???? Microsoft Internet Explorer ?? ???) ?? ???? ???? ???????? (???? Microsoft Office ?????? ?????) ?? ??? ?? ?????? ??? ???????? ???? ?? ???? WebBrowser ???????? ??? hosted ActiveX ???????? ????? ?????? ??; ?????, ???????? ???????? OLE ????????, ???? ?? ?????? ?? ??-????? ??????? ?? ??? sense ???

?????? ????? C# 2005 ?? ????? C# .NET ??????? ??? ?????? ???? ???????? ActiveX ????????? ????, ?? ??????? ?? ??? WebBrowser ???????? ????? ?? ???? ???? WebBrowser ???????? (Shdocvw.dll) Internet Explorer ?? ?? ??? ?? ?? ???? ???????? ?? ?????? Internet Explorer ??????? ???? ?? ???? ???

Office ???????? ???? ????? C# ????????? ?? ?? ????? ????? ??

????? ?? ??? ??? ????? C# ????????? ?? Office ????????? ????? ??, ????? ????? ?? ???? ????:
  1. ????? C# 2005 ?? Visual C# .NET ??? Windows ????????? ??? ??? ????????? ?????? Form1 ???????? ??? ?? ???? ??..

    ???:????? C# 2005, ??? ??? ?? SHDocVw.dll ????? ?? AxSHDocVw.dll ????? ???? ???? ????, ????? ???? ????? Visual Studio ????? ????????? ??:
    aximp %WINDIR%\system32\shdocvw.dll
    ???, ?? ??????? ???? ?????? ???????? (SHDocVw.dll) ?? ???? Windows ??????? ???????? (AxSHDocVw.dll) Microsoft ??? ???????? ???????? ?? ??? ?????? ????? C# 2005 ??? DLL ??????? ??????, ?? ????? ?? ???? ????:
    1. ????? ????????????????? ??,?????? ??????.
    2. ??????????? ??????????? ????? ???, ????? ???????????.
    3. ?????? ?????, ?? ???? ??? AxSHDocVw.dll ????? ?? SHDocVw.dll ????? ?? ??? ?????
    4. ?? ????? ??????? ?? ??? ????????? ?? ?????? ??????, ?? ??? ????? ????OK.
  2. ????? ????????????? ??,????? ????? ???????? ????????? ?? ???????? ????? ???????? ????????? ????? ?? ??????? ?? ??? ?? .. ????? ????COM ?????? ??, ??? ?????? ??????Microsoft WebBrowser. ????? ????,OKWindows ??? ??????? ????? ????? ?? ??? WebBrowser ???????? ??????? ??? ?? ??? WebBrowser ???????? ?? ????? ???? ??explorer????? ????? ????

    ???:Visual Studio 2005, ??? ???? ???? ??? 2 ?? ????
  3. ????? ?? ????? ??, ??? WebBrowser ????????, ?? OpenFileDialog ???????? ?? CommandButton ???????? Form1 ??????? ?? ????? ??AxWebBrowser1,OpenFileDialog1, ??Button1???? ?? ??? ????? ??Form1????? ????? C# 2005, ???webBrowser1,openFileDialog1, ??Button1????? ?? ????? ???? ????
  4. ???-????? Form1, ?? ????Button1. ?? ????? ??Button1_ClickForm1 ?? ??? ??????
  5. ??? ????? ??? Form1 ?? ???, ????? ??? ????? ?? ???? ??? ??????:
    using System.Reflection;
    					
  6. ???? ??? ???? ????? ????????? ????Form1???????????:
    private Object oDocument; 
  7. ?? ???InitializeComponent???? ?? ??? ????Form1, ????? ???? ?? ??? ????? ??? ??????Form1_Load,Form1_Closed, ??axWebBrowser1_NavigateComplete2?????:
    this.axWebBrowser1.NavigateComplete2 += new AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2);
    this.Load += new System.EventHandler(this.Form1_Load);
    this.Closed += new System.EventHandler(this.Form1_Closed);
    					
  8. ????? ??? ?? ???????????? ????
    private void button1_Click(object sender, System.EventArgs e)
    {
    }
    					
    with::
    private void button1_Click(object sender, System.EventArgs e)
    {
    
     String  strFileName;
    
     //Find the Office document.
     openFileDialog1.FileName = "";
     openFileDialog1.ShowDialog();
     strFileName = openFileDialog1.FileName;
    	        
     //If the user does not cancel, open the document.
     if(strFileName.Length != 0)
     {
      Object refmissing = System.Reflection.Missing.Value;
      oDocument = null;
      axWebBrowser1.Navigate(strFileName, ref refmissing , ref refmissing , ref refmissing , ref refmissing);
     }
    }
    
    public void Form1_Load(object sender, System.EventArgs e)
    {
     button1.Text = "Browse";
     openFileDialog1.Filter = "Office Documents(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt" ;
     openFileDialog1.FilterIndex = 1;
    }
    
    public void Form1_Closed(object sender, System.EventArgs e)
    {
     oDocument = null;
    }
    
    public void axWebBrowser1_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
    {
    
     //Note: You can use the reference to the document object to 
     //      automate the document server.
    
     Object o = e.pDisp;
       
     oDocument = o.GetType().InvokeMember("Document",BindingFlags.GetProperty,null,o,null);
    			
     Object oApplication = o.GetType().InvokeMember("Application",BindingFlags.GetProperty,null,oDocument,null);
    
     Object oName = o.GetType().InvokeMember("Name",BindingFlags.GetProperty ,null,oApplication,null);
    
     MessageBox.Show("File opened by: " + oName.ToString() ); 
    }
    					
    ???:?? Visual Studio 2005 ??? ??? ?? ????????? ???? ?????? ??? ???????? ??? ??, ????? C# ????? ??????? ?? ?? ????????? ?? ??? ?? ?? ?? Windows ??????? ????????? ????? ???? ?????? ?? Form1 ??? ??? ??????? ?? ???????????? ???? ???? ?? ??????? ??? Form1.cs ?? Form1.designer.cs ??? ???? Form1.cs ??? ??? ?????? Form1.designer.cs ????? ????? ???? Windows ??????? ??????? ?? ??? ?? ??? ???????? ???? ???? ?? ?? ?? ?????? ?? ????? ????? ?? ???????? ?? ??? ?? ?? ???

    ????? C# 2005 ??? Windows ??????? ??????? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ?????? ?? ???? ??????? (MSDN) ??? ????:
    HTTP://msdn2.Microsoft.com/en-us/library/ms173077.aspx
  9. ????????? ?? ????? ?? ??? F5 ?????.. ?? ?? ????? ???????????,?????????? ????? ????? ???? ??, ?? ?? ???? Word ????????, ???? Excel ????? ?????, ?? ???? PowerPoint ????????? ?? ??? ??????? ???? ?? ?????? ???? ??? ???? ?? ????? ?? ??? ????, ?? ???? ??? ????? ?????????. WebBrowser ???????? ?? ???? ????????? ????? ??, ?? Office ???????? ????? ?? ??? ????????? ???? ?? ?? ????? ????? ????? ???? ???

?? ?? WebBrowser ???????? ?? ????? ???? ?? ????? ???? ?? ??? ????

WebBrowser ???????? ?? ????? ???? ??? ?? ????? ?? ????? ???? ?????:
  • WebBrowser ???????? browses ?????????? ?? ??? asynchronously. ?? ?? ???WebBrowser1.Navigate, ??? ???? ?? ??? ???? ????? C# ????????? ???????? ???? ?????????????? ???? ??? ?? ??? ?? ??? ??? ??? ?? ???????? ?? ???? ??????? ?? ?? ??? ???, ?? ???? ?? ????? ????NavigateComplete2?? ???????? ??? ?? ?? ????? ???? ???? ?? ??? ?????? ??????????????? ???WebBrowserOffice ???????? ????????, ??, ????? ??? ???, ?? ??? ??? ?????? ?? ??????? ???? ??? ??? ???????? ?? ??? ??? ??oDocument.
  • WebBrowser ???????? ???? ???? ?? ?????? ???? ?????
  • Internet Explorer ??????? 5.0 ?? ??? ???, ??? ?? ????? ??? ?? ????? ???? docked ????? ???????? ????????? ?? ???? ???:
     // This is a toggle option, so call it once to show the 
     // toolbars and once to hide them. This works with Internet Explorer 5
     // but often fails to work properly with earlier versions.
     
     Object refmissing = System.Reflection.Missing.Value;
     axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,ref refmissing , ref refmissing);
    					
  • ?? ????? ???????? ?? ??? ??? ????????? ??? ?? ?? ???? WebBrowser ???????? ???? ?? ?? ??? ???????? ???????? ??? Office ???????? (??????, ??? Word ????????? ?? Excel ???????????? ?? ???) ?? ?? ?? ?????? ?? ??? ???? ???? Microsoft ??????? ???? ?? ?? ?? ???????? ????????? ?? ??? ???? ?? ???????? ?? ????? ????, ?? ?? ??? ??? ?? ???????? ?? ??? ??????? ?????

    Microsoft Office ???? ?????, ?? ????? ??? ???? ???? ?? ?????? ??? ??? ???? ??? ?? ?? ??????? ?? ?? WebBrowser ???????? ??, ????? ?? ?????? Word ???????? ?? ??? ??? ???? ???, ?? ??? ?? ?? ????????? ??????? ?? ????? ?? ????? ????? ????????? ??, ????? ???????? ?? ???? ?? ??? ?????? ?? ?? ??? ?? ??? ????? ???? ????? ???? ??? ?? ?? ????? ???? ???? ?? ???? ???
  • ??? WebBrowser ???????? ?? ???? ??????? ??????? ?? ????? ???? ?? ???????? ????,???? ???? ??? (?? ??? ???? ??????? ????? ??? ???? ??? ???), ????? ?????? ???? ?? ??? ????? ??? ?? ?????? ???? ??????? ????? ?????:
       AxWebBrowser1.Navigate("about:blank");
    					

?? ?? ?? 2007 Office ????????? ?? ??? WebBrowser ???????? ????? ???? ?? ????? ???? ?? ??? ????

???????? ??? ??, 2007 Office ????????? ???? ??? Office ???????? ??? ??????? ??? ??? ?? ??????? ?? WebBrowser ???????? ?? ???????? ?????? ?? ???????? ?? ?? ?? ?? ????? ????? ActiveX ???????? ???????? WebBrowser ???????? ?? ????? ?? ?? ?? 2007 Office ????????? ?? ????? ?? ?? ????????? ?????? ???? ????For more information about custom ActiveX document containers, click the following article number to view the article in the Microsoft Knowledge Base:
311765Visual C++ ActiveX control for hosting Office documents in Visual Basic or HTML
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.???? ??????? ?? ???, Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ????? ????::
927009??? ?? ????? ????? ?? ?? ?? Windows Internet Explorer 7 ??? ?? 2007 Microsoft Office ????????? ???????? ????? ?? ?????? ????
???:??? ?? ????????? ?? ??????? 927009 Microsoft ???????? ???? ??? ?????? ???? ?? ????? ???? ???, ???????? WebBrowser ???????? ??? ????????? ?? ????? ???? ???? ?? ???????? ???? ???? ???????? Internet Explorer ?? ??? ?????????? ?? ?? ???????? ???? ???? ??? ??, ?? ???? Microsoft Office ?????? ?? ???? ?? ???? ????????? ?? ??? ??? ???? ?? ???? ??? ?????, ?? ??????? ???? ??? ?? ???? ???? ?????? ????????? ?? ??? ?????? ?? ??? ?? ?? ???? ?? ????? ?????

??????

WebBrowser ???????? ?? ????? ???? ?? ???? ??? ???? ??????? ?? ??? ?????? ?? Microsoft ???????? ??? ????? ?? ??? ????? ???? ???????? ?? ????? ????:
304562????? Studio 2005 ?? Visual Studio .NET ???? ???? ?? OLE ???????? ???????? Windows ??????? ?? ???
243058?? Office ????????? ?? ????? ?? ??? WebBrowser ???????? ?? ????? ???? ????
162719Visual Basic 5.0 ?? WebBrowser ???????? ?? ????? ???? ????
202476BUG: OLE ?? WebBrowser ???????? ??? Word ???????? ?? ??????? ???? ?? ????
188271??? ???????? ???????? ?? ??????? ?? VB ?? ??????? ???? ?? ??? ???? ????
191692Shdocvw.dll PDW ????? ?????? ??? ????? ???? ??
238313Visual Basic ?? Internet Explorer ???????? ???????? ???? ?? ????? ??? ??
927009??? ?? ????? ????? ?? ?? ?? Windows Internet Explorer 7 ??? ?? 2007 Microsoft Office ????????? ???????? ????? ?? ?????? ????

???

???? ID: 304662 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Office Excel 2007
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Office PowerPoint 2007
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft PowerPoint 2000 Standard Edition
  • Microsoft Office Word 2007
  • Microsoft Word 2002
  • Microsoft Word 2000
??????: 
kbactivedocs kbautomation kbhowto kbwebbrowser kbmt KB304662 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:304662

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com