Reputation: 111
I have a template named MorningReport.xltm I have a macro that copies data from a file and pastes it into the file. The problem is that when the user opens the file, it renames it to MorningReport1 and I can't figure out what the file extension is on that new one? When I go to run the macro, it can't find the file (b/c I am assuming I am not putting the right extension on it). Any solutions or insight into how template referencing works or how to outright solve my problem would be fantastic!
Thanks!
Upvotes: 1
Views: 184
Reputation:
It doesn't have an extension.
Just as a new blank workbook is called Book1 and not Book1.xlsx or Book1.xlsm or Book1.xlsb without saving the workbook, your template has created a new, blank workbook based on the .xltm template. It will not have an associated extension until it has been saved as one of the workbook XlFileFormats.
This behavior can be verified by going into the VBE and typing ?thisworkbook.name
into the Immediate window.
Upvotes: 1