COleVariant covZero((short)0),covTrue((short)TRUE);
wd.m_wdView.SetSeekView(10); // wdSeekCurrentPageFooter=10
wd.m_wdParagraphFormat=wd.m_wdSel.GetParagraphFormat();
wd.m_wdParagraphFormat.SetAlignment(pFrame->m_dlgPrintSet.m_printInfo.m_PagenumPosition);
// 添加頁碼
if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 0)
{
wd.m_wdSel.TypeText(LPCTSTR(_T(" ")));
}
else if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 1)
{
wd.m_wdSel.TypeText(LPCTSTR(_T("..")));
}
else if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 2)
{
wd.m_wdSel.TypeText(LPCTSTR(_T("--")));
}
else if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 3)
{
wd.m_wdSel.TypeText(LPCTSTR(_T("第頁")));
}
else if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 4)
{
wd.m_wdSel.TypeText(LPCTSTR(_T("第頁 共頁")));
}
if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType != 4)
{
wd.m_wdSel.MoveLeft( COleVariant((short)1), COleVariant((short)1), &covZero );
}
else if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 4)
{
wd.m_wdSel.MoveLeft( COleVariant((short)1), COleVariant((short)4), &covZero );
}
wd.m_wdFields = wd.m_wdSel.GetFields();
// 增加頁碼域,當前頁碼
int i = wd.m_wdFields.GetCount();
wd.m_wdFields.Add( wd.m_wdSel.GetRange(), COleVariant((short)33), COleVariant(_T("PAGE ")), &covTrue );
if (pFrame->m_dlgPrintSet.m_printInfo.m_PagenumType == 4)
{
wd.m_wdSel.MoveRight( COleVariant((short)1), COleVariant((short)3), &covZero);
//增加頁碼域,總頁數
wd.m_wdFields.Add( wd.m_wdSel.GetRange(), COleVariant((short)26), COleVariant(_T("NUMPAGES ")), &covTrue ); // 增加頁碼域,總頁數
}
wd.m_wdView.SetSeekView(0); // 關閉頁眉頁腳,wdSeekMainDocument=0,回到主控檔案
uj5u.com熱心網友回復:
這是經驗分享么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/98288.html
