[archive] Setting the Heading and Footer When Exporting Information to Excel 2007

[Migrated content. Thread originally posted on 11 April 2007]

I am exporting data to Excel using the Application, Workbook, Worksheet and Range objects. I was able to set the Header and Footers for the current version of Excel(2003) that I have on my computer. The code that I am using is

MODIFY EX-WORKSHEET @PageSetup::LeftHeader = GUI-HEADER-TITLE.
MODIFY EX-WORKSHEET @PageSetup::LeftFooter = FOOTER-DATE.
MODIFY EX-WORKSHEET @PageSetup::CenterFooter = PROJECT-NAME.
MODIFY EX-WORKSHEET @PageSetup::RightFooter = %P.

So currently when I do the export to Excel and print the Excel spreadsheet, it will print the header and footers correctly.

Now I just tested this on Excel 2007 and I get an error when my program hits the above code and will not continue with the export to Excel. According to the online documentation on the MSDN website about Excel 2007, the PageSetup property is part of the Worksheet Object, so I am not sure why I am getting an error? Error I am gettting is "Unable to set the LeftHeader property of the PageSetup class". I am new to doing the export to Excel this way, so maybe it is just something that I don't understand.


Does anyone have any ideas?