??? ??? ??????? ????? Get ? ????? ????? ????? Office ???????? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 303296 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

??????

???? ??? ??????? ????? ????? Microsoft Visual C# .NET ?????? ??????? ???? ????? ????? ????? Microsoft Word. ??? ????? ?? ????? ???????? ???????? ?????? ?? Word ? ????? ????? ??? ???????? ??? ????? Microsoft Excel ? Microsoft PowerPoint.

??????? ????

????? ???? ??????? ??? Microsoft Word

  1. ??? ????? Visual Studio .NET.
  2. ?? ??????? ???? ???? ??? ???? ?? ???? ??? ???????. ??? ????? Windows ?? ??????? ?????? Visual C#. ??? ????? Form1 ???? ???????.
  3. ????? ???? ??? ????? ?????? Microsoft Word. ?????? ????? ???? ??????? ???????:
    1. ?? ??????? ??????? ???? ??? ????? ????.
    2. ??? ????? ??????? COM ????? ???? ????? ?????? Microsoft Word ?? ???? ??? ?????.

      ?????? ????? Microsoft Office 2003 "????????? Interop ????????" (PIAs). Microsoft Office XP ?? ????? PIAs ???? ???? ???????. ?????? ??? ??????? ?????? ??? Office XP PIAs ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
      328912INFO: Microsoft Office XP PIAs ?? ???????? ???????
    3. ???? ??? ????? ?? ???? ?????? ????? ????? ????? ?????????. ??? ??? ??????? ?????? wrappers ???????? ???? ?????? ???? ??? "???".
  4. ?? ??????? ???? ??? Toolbox ???? ???? ??????? ?? ?? ?????? ?? ??? Form1.
  5. ???? ????? ??????? ??? Button1. ???? ???? ????????? ???????? ???????.
  6. ?? ???? ????????? ???????? ??????? ???????? ???????? ???????
    private void button1_Click(object sender, System.EventArgs e)
    {
    }
    					
    ??:
    private void button1_Click(object sender, System.EventArgs e)
    {
       Word.Application oWord;
       Word._Document oDoc;
       object oMissing = Missing.Value;
       object oDocBuiltInProps;
       object oDocCustomProps;
    			
       //Create an instance of Microsoft Word and make it visible.
       oWord = new Word.Application();
       oWord.Visible = true;
    
       //Create a new Document and get the BuiltInDocumentProperties collection.
       oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, 
                                  ref oMissing);
       oDocBuiltInProps = oDoc.BuiltInDocumentProperties;
       Type typeDocBuiltInProps = oDocBuiltInProps.GetType();
    
       //Get the Author property and display it.
       string strIndex = "Author";
       string strValue;
       object oDocAuthorProp = typeDocBuiltInProps.InvokeMember("Item", 
                                  BindingFlags.Default | 
                                  BindingFlags.GetProperty, 
                                  null,oDocBuiltInProps, 
                                  new object[] {strIndex} );
       Type typeDocAuthorProp = oDocAuthorProp.GetType();
       strValue = typeDocAuthorProp.InvokeMember("Value", 
                                  BindingFlags.Default |
                                  BindingFlags.GetProperty,
                                  null,oDocAuthorProp,
                                  new object[] {} ).ToString();
       MessageBox.Show( "The Author is: " + strValue,"Author" );
    
       //Set the Subject property.
       strIndex = "Subject";
       strValue = "The Subject";
       typeDocAuthorProp.InvokeMember("Item", 
                                  BindingFlags.Default | 
                                  BindingFlags.SetProperty, 
                                  null,oDocBuiltInProps, 
                                  new object[] {strIndex,strValue} );
    			
       //Add a property/value pair to the CustomDocumentProperties collection.
       oDocCustomProps = oDoc.CustomDocumentProperties;
       Type typeDocCustomProps = oDocCustomProps.GetType();
    
       strIndex = "Knowledge Base Article";
       strValue = "Q303296";
       object[] oArgs = {strIndex,false,
                         MsoDocProperties.msoPropertyTypeString,
                         strValue};
    
       typeDocCustomProps.InvokeMember("Add",BindingFlags.Default | 
                                  BindingFlags.InvokeMethod, null, 
                                  oDocCustomProps, oArgs );
    
       MessageBox.Show("Select \"Properties\" from the File menu "
            + "to view the changes.\nSelect the Summary tab to view "
            + "the Subject property and the Custom tab to view the Knowledge"   
            + "Base Article property.", "Check File Properties",
            MessageBoxButtons.OK,MessageBoxIcon.Information);
    }
    					
  7. ??????? ??? ???? ???? ????????? ???????? ?? ?? ?????? ?????? ??????? ??? ????? ??????? ???????? ???????:
    using Microsoft.Office.Core;
    using Word = Microsoft.Office.Interop.Word;
    using System.Reflection;
    					
  8. ???? F5 ?????? ???????.
??????DocumentProperties ??????? DocumentProperty ?????? ????? ???????. ???????? ??? ???????? ??? ?????? ????? ??? ???? ?? ????? IDispatch.

?????

????? ?? ?????????? ?? ?????? ?????? Microsoft ??????? ???? "??? ??????":
????? Microsoft Office ?? Visual Studio
http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx
?????? ??? ??????? ??????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
303294????? ??????? ????? Get ?? ????? ????? ????? Office ???????? Visual Basic .NET

???????

???? ???????: 303296 - ????? ??? ??????: 11/????/1428 - ??????: 6.4
????? ???
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
????? ??????: 
kbmt kbpia kbautomation kbhowto KB303296 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????303296

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

 

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