none
Document properties not Displaying in Window Explorer RRS feed

  • Question

  • I've written an application that will add some Document properties and move the file to a specified folder location.

    At the time Office 2003 was installed.  Since then Office has been upgraded to 2007.

    The code works in that it adds the properties to the file and saves the file in the correct format (.doc)

    But the properties do not show in Window Explorer until I open the file and re-save.

    Can anyone see what I have done wrong?

    //Open Existing Word Document and get the BuiltInDocumentProperties collection.
                
    oDoc = oWord.Documents.Open(sourceFile, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
    
    oDocBuiltInProps = oDoc.BuiltInDocumentProperties;
    Type typeDocBuiltInProps = oDocBuiltInProps.GetType();
    
     //Get the Properties and Set.
    object oBookAuthorProp = typeDocBuiltInProps.InvokeMember("Item",
    BindingFlags.Default |
    BindingFlags.GetProperty,
    null, oDocBuiltInProps,
    new object[] { "Author" });
    object oBookCommentProp = typeDocBuiltInProps.InvokeMember("Item",
    BindingFlags.Default |
    BindingFlags.GetProperty,
    null, oDocBuiltInProps,
    new object[] { "Comments" });
    
    Type typeDocAuthorProp = oBookAuthorProp.GetType();
    Type typeDocCommentProp = oBookCommentProp.GetType();
    
    typeDocAuthorProp.InvokeMember("Item",
    BindingFlags.Default |
    BindingFlags.SetProperty,
    null, oDocBuiltInProps,
    new object[] { "Author", myName });
    typeDocCommentProp.InvokeMember("Item",
    BindingFlags.Default |
    BindingFlags.SetProperty,
    null, oDocBuiltInProps,
    new object[] { "Comments", myChanges });
    
    //Save File and Close All Objects.
    oDoc.Close(true, oMissing, oMissing);
    
    I have also tried oDoc.SaveAs(LastName, Word.WdSaveFormat.wdFormatDocument);
    

    Thursday, April 14, 2011 8:23 AM

All replies

  • Hello,

    Make sure there're no winword.exe instances hanging in the Task Manager window.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, April 14, 2011 12:14 PM