㈠ vc++操作word 如何從指定的頁添加頁眉和頁腳。我現在添加的頁眉是從首頁開始的,我想從第三頁再開始添加。
vc前面定義文檔對象,打開word什麼的就不啰嗦啦,關鍵代碼如下:
……
Window mWindowActive; //定義活動窗口對象
View mViewActive; //定義活動視圖對象
Pane mPane; //定義當前窗格對象
mWindowActive=app.GetActiveWindow(); //獲得當前窗口
mPane=mWindowActive.GetActivePane(); //獲得當前窗格
mViewActive=mPane.GetView(); //獲得當前視圖
mViewActive.SetSeekView(9); //設置頁眉視圖
font.SetSize(10);
sel.TypeText("XXXXXXXXXXXXXXXXXX有限公司");
para.SetAlignment(1); //居中
sel.TypeParagraph();
font.SetSize(11);
sel.TypeText("計 算 書 專 用 紙");
para.SetAlignment(1); //居中
font.SetSize(10);
mViewActive.SetSeekView(10); //設置頁腳視圖
sel.TypeText("- ");
fields.Add(sel.GetRange(),COleVariant(short(33)),COleVariant("PAGE "),vFalse1); //增加頁碼域
sel.TypeText(" -");
para.SetAlignment(1); //居中
mViewActive.SetSeekView(0); //回到正文視圖
……