翻譯|使用教程|編輯:胡濤|2022-04-18 10:32:51.063|閱讀 322 次
概述:
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
使用 Spire.Doc,開發人員可以快速檢測 Word 文檔是否包含 VBA 宏,并從 Word 文檔中刪除所有 VBA 宏。本文將向您展示如何使用 Spire.Doc 從 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 object Document document = new Document(); //Load the Word document document.LoadFromFile("Input.docm"); //If the document contains macros, remove them from the document if (document.IsContainMacro) { document.ClearMacros(); } //Save the document document.SaveToFile("Output.docm", FileFormat.Docm); } } }
歡迎下載|體驗更多E-iceblue產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn