Click here to Skip to main content
15,901,426 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionNot able to set header and footer in excel on multiple (even or odd pages) Pin
I_am_nayak16-May-23 19:19
I_am_nayak16-May-23 19:19 
Below is my code but note working same header footer is set to all page, please suggest best solution for this.

oWorkSheets2007 = oWorkBook2007.GetWorksheets();
oWorkSheet2007 = oWorkSheets2007.GetItem(COleVariant((short)sheetNum));
XLS2007::Window owindObj = oApp2007.GetActiveWindow();
XLS2007::Pages oPages = owindObj.GetPanes();
oPageSetup = oWorkSheet2007.GetPageSetup();
oPages = oPageSetup.GetPages();
long a = oPages.GetCount();

int l=0;
for( l=l+1;l<=a;l++)
{
oPage= oPages.GetItem(COleVariant((short)l));
oPageSetup = oWorkSheet2007.GetPageSetup();
oPageSetup.SetPrintErrors(1);
oPageSetup.SetAlignMarginsHeaderFooter(HFI.bAlignWithMargins);
oPageSetup.SetScaleWithDocHeaderFooter(HFI.bScaleWithDoc);
oPageSetup.SetCenterHeader(LPCTSTR(HFI.FirstCentreHeader));
oPageSetup.SetCenterFooter(LPCTSTR(HFI.FirstCentreFooter));
oPageSetup.SetLeftHeader(LPCTSTR(HFI.FirstLeftHeader));
oPageSetup.SetLeftFooter(LPCTSTR(HFI.FirstLeftFooter));
oPageSetup.SetRightHeader(LPCTSTR (HFI.FirstRightHeader));
oPageSetup.SetRightFooter(LPCTSTR(HFI.FirstRightFooter));
oPageSetup.SetCenterHeader(LPCTSTR(HFI.OddCentreHeader));
oPageSetup.SetCenterFooter(LPCTSTR(HFI.OddCentreFooter));
oPageSetup.SetLeftHeader(LPCTSTR(HFI.OddLeftHeader));
oPageSetup.SetLeftFooter(LPCTSTR(HFI.OddLeftFooter));
oPageSetup.SetRightHeader(LPCTSTR(HFI.OddRightHeader));
oPageSetup.SetRightFooter(LPCTSTR(HFI.OddRightFooter));
AnswerRe: Not able to set header and footer in excel on multiple (even or odd pages) Pin
David Crow17-May-23 2:23
David Crow17-May-23 2:23 
QuestionMessage Closed Pin
14-May-23 13:20
polcott14-May-23 13:20 
AnswerRe: Can D simulated by H terminate normally? Pin
Richard MacCutchan14-May-23 21:39
mveRichard MacCutchan14-May-23 21:39 
AnswerRe: Can D simulated by H terminate normally? Pin
jschell15-May-23 4:58
jschell15-May-23 4:58 
GeneralMessage Closed Pin
15-May-23 8:30
polcott15-May-23 8:30 
GeneralRe: Can D simulated by H terminate normally? Pin
harold aptroot15-May-23 9:20
harold aptroot15-May-23 9:20 
GeneralMessage Closed Pin
15-May-23 9:50
polcott15-May-23 9:50 
GeneralRe: Can D simulated by H terminate normally? Pin
harold aptroot15-May-23 10:03
harold aptroot15-May-23 10:03 
GeneralMessage Closed Pin
16-May-23 4:51
polcott16-May-23 4:51 
GeneralRe: Can D simulated by H terminate normally? Pin
jschell16-May-23 6:41
jschell16-May-23 6:41 
GeneralMessage Closed Pin
18-May-23 4:27
polcott18-May-23 4:27 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 5:03
jeron118-May-23 5:03 
GeneralMessage Closed Pin
18-May-23 5:16
polcott18-May-23 5:16 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 5:22
jeron118-May-23 5:22 
GeneralMessage Closed Pin
18-May-23 5:51
polcott18-May-23 5:51 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 6:07
jeron118-May-23 6:07 
GeneralMessage Closed Pin
18-May-23 6:28
polcott18-May-23 6:28 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 6:37
jeron118-May-23 6:37 
GeneralMessage Closed Pin
18-May-23 6:46
polcott18-May-23 6:46 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 6:52
jeron118-May-23 6:52 
GeneralMessage Closed Pin
18-May-23 7:09
polcott18-May-23 7:09 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 7:29
jeron118-May-23 7:29 
GeneralMessage Closed Pin
18-May-23 7:37
polcott18-May-23 7:37 
GeneralRe: Can D simulated by H terminate normally? Pin
jeron118-May-23 7:39
jeron118-May-23 7:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.