Word控件Spire.Doc 【文档操作】教程(十六):在 C# 中从 Word 文档中检测和删除 VBA 宏

详细步骤:

第 1 步初始化 Document 对象并加载 Word 文档

Document document = new Document();document.LoadFromFile("Input.docm");

第 2 步如果文档包含宏,请将它们从文档中删除。

if (document.IsContainMacro){document.ClearMacros();}

第 3 步保存文档。

document.SaveToFile("Output.docm", FileFormat.Docm);

完整代码

using Spire.Doc;namespace Remove_Macros_from_Word{class Program{static void Main(string[] args){//Initialize a Document objectDocument document = new Document();//Load the Word documentdocument.LoadFromFile("Input.docm");//If the document contains macros, remove them from the documentif (document.IsContainMacro){document.ClearMacros();}//Save the documentdocument.SaveToFile("Output.docm", FileFormat.Docm);}}}

欢迎下载|体验更多E-iceblue产品

如需获取更多产品相关信息请咨询在线客服  

Word控件Spire.Doc 【文档操作】教程(十六):在 C# 中从 Word 文档中检测和删除 VBA 宏

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年3月15日
下一篇 2022年3月15日

相关推荐

发表回复

登录后才能评论