Followup to deletion of builtin properties

Add-in Express™ Support Service
That's what is more important than anything else

Followup to deletion of builtin properties
 
Steve Obarowski


Guest


I am now trying to simply blank out those values as opposed to deleting them, and it just isn't quite working as I expect it to. Here is the code:

Document activeDocument = (AddinModule.CurrentInstance).WordApp.ActiveDocument;
DocumentProperties props = activeDocument.BuiltInDocumentProperties as DocumentProperties;
List<metadataClass> metaList = clbMetadata.CheckedItems.Cast<metadataClass>().ToList();
foreach (metadataClass item in metaList)
{
DocumentProperty prop = props[item.Name];
if (prop != null)
{
props[item.Name].Value = string.Empty;
}
}

//activeDocument.Save();

The properties I am most interested in are "Author" and "Last author"

1) I select Author and Last Author, and it appears only Author gets blanked out.
2) With the activeDocument.Save activated, I close the document and Author comes back when I open it again.
3) If I go to File->Save in Word (or click the save icon at the top), the Author property remains blank and works as I expect it to.
4) If I do a Save As, the Author comes back.

So, my questions are:
Is it possible to change the value of "Last author"?
Why doesn't ActiveDocument.Save() retain the Author change?
What causes the SaveAs to behave differently than the Save in Word?
Do you possibly have some alternative code?

Thanks,
Steve Obarowski
Posted 06 Feb, 2017 13:16:03 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Steve,

I confirm the issue: I can't overwrite the Last Author property. I suppose this is by design. But sincerely, I don't know. Tomorrow, I ask this question on the Word for Developers forum and copy a link here.


Andrei Smolin
Add-in Express Team Leader
Posted 07 Feb, 2017 10:56:51 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Posted 08 Feb, 2017 04:27:31 Top
Steve Obarowski


Guest


Thanks Andrei,

The activeDocument.Saved = false worked for the Author, and I now have an explanation for the Last Author property (user must be logged out for that to take effect).

One last question, and I'm assuming the answer is no. Is it possible to turn off or clear out the statistics in the built in properties? We have a customer who wants to be able to clear out "Total Edit Time" (I have no earthly idea why), but I would think that statistics are automatically generated on a save.

Thanks again,
Steve Obarowski
Posted 08 Feb, 2017 09:52:57 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Steve,

I'm afraid I don't know the answer. I would suggest that you try the tricks above: set the property to zero programmatically, modify it at run time, log off, etc.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Feb, 2017 10:01:14 Top