Custom footer will not print from Macro

sbuca76

New Member
Joined
Mar 22, 2011
Messages
2
I have recorded a macro in Excel 2010 which contains, as part of it, inserting a custom footer, specifically the file name. When the macro is run, the filename disappears even though the macro code shows the center footer containing the code "&F". Is this a bug or is there an update for it?
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

jae113

Board Regular
Joined
Jun 17, 2008
Messages
227
I was having the same problem. I found this workaround on Microsoft's site

In place of your VBA code that gets recorded, in the appropriate footer or header section do the following (hit ALT+F11 to get to the VBA editor and open the Module on the left side that was created):
To show the current page number replace &P with &P[]
To show the number of pages in your workbook, replace &P with &N[]
To show the current date, replace &D with &D[]
To show the current time replace &T with &T[]
To show the file path replace &P or whatever got recorded with &Z[]
To insert the current file name replace &F with &F[]
To insert the sheet name replace &Tab with &A[]
 

jae113

Board Regular
Joined
Jun 17, 2008
Messages
227
I just found a better way to make this work. PrintCommunication is new to 2010 (maybe 2007 too, I don't know) and it will come up in your macro, especially if you use the recorder.

Remove all Application.PrintCommunication, it can be true or false, from your macro.

Headers and Footers should work fine!

The macros do work a little slower, but it seems ok
 

Watch MrExcel Video

Forum statistics

Threads
1,122,962
Messages
5,599,065
Members
414,281
Latest member
Engjamal2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top