Forum Discussion
Remove File Extension in Custom Header in an Excel Sheet
Hello,
what you describe can only be done with VBA. You need to add this code to the ThisWorkbook module:
Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.CenterHeader = UCase(Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 5)) End Sub
Hello Ingeborg, Thanks
Can I use this code for all types of workbooks, be it .xlsx or .xltx? Do I need to save the workbook as .xlsm, i.e as macro-enabled workbook? If so, how can use .xlsm workbook as a template?
- Jun 05, 2018
Hello,
if you use this approach, the workbook must be saved as a macro-enabled workbook, i.e. with either the .xlsm or .xlsb file extension.
You can create a template that contains this macro by saving the file as a macro-enabled template with the .xltm extension.
- aredevJun 06, 2018Copper ContributorThanks a ton! I'll connect back if I need any further assistance. Cheers! :D
- aredevJun 06, 2018Copper Contributor
In continuation of my reply a few minutes back. I got a very simple solution from another forum. Change the view options in Windows Explorer, the file extension display changes accordingly & that too instantly. No need for macros.