使用xml删除的跟踪更改不适用于.net中的document.close

使用xml删除的跟踪更改不适用于.net中的document.close,.net,openxml,.net,Openxml,我正在使用实用程序从word文档中删除曲目格式。如果我不使用document.close,它可以正常工作。下面是我正在使用的方法 private static void RemoveTrackChangesFormattingFromTheDocument(ref WordprocessingDocument document) { Program.AcceptAll(document);//this method will remove all the format changes

我正在使用实用程序从word文档中删除曲目格式。如果我不使用document.close,它可以正常工作。下面是我正在使用的方法

private static void RemoveTrackChangesFormattingFromTheDocument(ref WordprocessingDocument   document)
{
  Program.AcceptAll(document);//this method will remove all the format changes
  //it is working fine if i will not use
  document.close();
}
请帮帮我


谢谢

可能是您的
AcceptAll
方法正在使用
using
,例如

using (WordprocessingDocument doc =
    WordprocessingDocument.Open("DocumentWithRevisions.docx", true))
{
    RevisionAccepter.AcceptRevisions(doc);
}
因此,只要到达右大括号,就会自动调用
.Close

供参考: