Search code examples
c#comms-word

C# and Word2010 : DeleteAllComments throws "This command is not available."


I wrote a small C# Tool deleting all comments within a word file using COM.

Formerly our company used WinXP + Office2003 and all worked perfect.

Now we switched to Win7 and Office2010 (64-bit).

With the new OS and Office version the DeleteAllComments Line leads to an exception called "This command is not available." but missing any further explaination.

Microsoft.Office.Interop.Word.Document document;
object missing = System.Reflection.Missing.Value;
document = wordInstance.Documents.Open(ref filename, ref missing, ref   ReadOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

document.Activate();
document.AcceptAllRevisions();
document.DeleteAllComments();

The rest of the code works perfect... can anybody help?

Thnx in advance.

Greetings Michael


Solution

  • My problem seems to come from the very restrictive security policies within this company. No macros allowed under Office2010 and no way for a normal user to turn them on.

    (For all outside my company check the setting: File-->Options-->SecurityCenter-->Macros)

    Hope that helped.