2
我想使用詞自動化在Word文檔中插入頁眉或頁腳。如何使用C++自動化將標題或頁腳插入word文檔
_document ocDoc;
Sections DocSections = Sections(ocDoc.GetSections());
section firstSec = DocSections.Item(1);
HeaderFooter Hf = firstSec.GetHeaders();
Range MyRange = Hf.GetRange();
MyRange.SetText(L"salam");
但部分代碼 「範圍MyRange = Hf.GetRange();」失敗, 如何插入頁眉或頁腳在Word文檔中使用C++?
下面的c#正常工作代碼:
_document ocDoc;
oDoc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "My Header";
當你說它失敗了 - 那有什麼做的正是?拋出一個異常,崩潰,返回NULL,別的東西? –
這看起來很棒。我仍然使用OLEMethods,你能否爲我提供一些_document和Section類的代碼。 – masche