Changing file format on a template

Praedico

New Member
Joined
Jul 17, 2008
Messages
43
Windows system - Excel 2003

Is there a way to change the default 'save-as' filetype in an 'opened' template from XLT to XLS?

I'm thinking perhaps VBA code in the ThisWorkbook object when the template is opened.

I don't want the user to have to select it ... because they won't. They'll just blindly save it as an XLT and it will create a mess.


Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
The following macro (placed in personal.xls) will automatically save the file using the existing file name as an xml extension.

is this what you wanted?

Code:
If InStrRev(ActiveWorkbook.Name, ".") > 0 Then     
   ActiveWorkbook.SaveAs Left(ActiveWorkbook.Name, InStrRev(ActiveWorkbook.Name, ".") - 1) & ".xml", FileFormat:=46 
Else     
   MsgBox "Save with a valid filename before saving as .xml" 
End If
Maybe create a Macro Button and label it as "Save" for everyone to use.
 
Last edited:
Upvote 0
The following macro (placed in personal.xls) will automatically save the file with the existing file name as an xml extension.

is this what you wanted?

Code:
If InStrRev(ActiveWorkbook.Name, ".") > 0 Then     
ActiveWorkbook.SaveAs Left(ActiveWorkbook.Name, InStrRev(ActiveWorkbook.Name, ".") - 1) & ".xml", FileFormat:=46 Else     
MsgBox "Save with a valid filename before saving as .xml" 
End If


Thanks for the quick response - actually I don't want them to be asked to save the file. I just want to change the default filetype so that when they are ready to save it defaults to the xls instead of xlt.
 
Upvote 0
This code can go in the ThisWorkbook instead of personal.xls

Code:
If InStrRev(ThisWorkbook.Name, ".") > 0 Then     
  ActiveWorkbook.SaveAs Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1) & ".xml", FileFormat:=46 
Else     
  MsgBox "Save with a valid filename before saving as .xml" 
End If
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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
Back
Top