I recorded an Excel macro that places a footer with date/time on the left, Page x of y on the right and when the file is previewed either the data is garbeled on the left or it says "Page 1 of" on the right (without the total pages)
This same macro has been recorded in Office 2007 without any issues. Any one know the "fix" for this?
Thanks!
File is attached with a preview of the garbled that is showing on the right and code is also attached.
Try recording the macro and use the line that you get
i have got one line if it could help
.RightFooter = "&""Times New Roman,Bold Italic""Page &P of &N"
jrogersok
ASKER
Tried your code and still didn't work -- the issue seems to be with it not understanding the code recorded or entered. Perhaps a Service Pack fixes this? We do not have any installed at the company's site.
I am teaching a class of vba students and they are all having the issue so i'm sure it's something with the recorder/objectlibrary in Excel itself. Thanks for the tips.
Would like a permanent solution rather than a work-a-round (although if I could get a work around, at least I could share it)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Hello,
there is a bug in Excel 2010 with regards to some of the footer codes. For the ones that don't work, append a set of square brackets, like this
.RightFooter = "page &P of &N[]"
In my trials, the &P worked fine, but the &N did not. Adding the [] after &N did the trick. But when I added ...
.LeftFooter ="page &P"
... to the code, I had to use...
.LeftFooter ="page &P[]"
.RightFooter = "page &P of &N[]"
... to make the whole parcel work.
So, it also seems to depend on whether or not there's stuff in the left footer, and what that stuff is. Just play around with adding the square brackets.
IMPORTANT: Before you run the macro, manually clear existing footers, because they will not always be overwritten and results may look funny.
i have got one line if it could help
.RightFooter = "&""Times New Roman,Bold Italic""Page &P of &N"