文檔半島外圍網上直營>>E-iceblue中文文檔>>從 Word 文檔中檢測和刪除 VBA 宏
                從 Word 文檔中檢測和刪除 VBA 宏
使用 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產品


 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線