技術文章 > 通過 OLE 訪問 Microsoft Word

通過 OLE 訪問 Microsoft Word

2019-07-01 08:01

文檔管理軟件,文檔管理系統,知識管理系統,檔案管理系統的技術資料:

#include "WordOle.h"
Variant Word;
Variant Documents;
Variant ActiveDocument;
// Create Word Application
Word = CreateOleObject("Word.Application");
// Quit Word
Word.OleFunction("Quit",wdDoNotSaveChanges);
// Get Document
Documents = Word.OlePropertyGet("Documents");
// New A Document
Documents.OleFunction("Add");
// Get Active Document
ActiveDocument = Word.OlePropertyGet("ActiveDocument");
// Open A Document
Documents.OleFunction("Open" , FileName);
// Get Active Document
ActiveDocument = Word.OlePropertyGet("ActiveDocument");
// Save
ActiveDocument.OleFunction("Save");
// SaveAs
ActiveDocument.OleFunction("SaveAs",FileName);
// Print Preview
ActiveDocument.OleFunction("PrintPreview");
// Print
ActiveDocument.OleFunction("PrintOut");
不知道 Excel 是否類似。
:)
体彩7星彩规则