how to save file as 97-2003 xls not xlsx in vba

Ceri_m

New Member
Joined
Mar 2, 2011
Messages
5
Hi there, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
I’ve got a file which from a macro sorts the data then splits it into sections, then creates a new workbook for each section, renames the tabs and and saves the new files as the tab name, for us to email out to different companies. The problem I’ve got, is that the companies that we’re sending to all have different versions of Excel, and we’re getting errors coming back each time as to being able to open the file, or the file being corrupted. What I’d like, is to save the files as 97-2003 xls, so everyone can open them, but no matter what I’ve tried (so far) in the fileformat, it saves as xlsx, which the people with earlier versions of Excel don’t seem to be able to open. I’ve tried adding “.xls” to the end of the file name, but then it comes up with the error ‘the file format is different to the file extension’. For some users this is fine, but again for earlier users, the file corrupts.<o:p></o:p>
<o:p></o:p>
So far I’ve tried:<o:p></o:p>
<o:p></o:p>
…Other code…. <o:p></o:p>
Dim FileExtStr As String<o:p></o:p>
Dim FileFormatNum As Long<o:p></o:p>
Dim FileFormatType As String<o:p></o:p>
FileExtStr = ".xls": FileFormatNum = 56: FileFormatType = "xlExcel8"<o:p></o:p>
<o:p> </o:p>
Then further down when it’s created the new workbook<o:p></o:p>
With NewWB<o:p></o:p>
FileExtStr = ".xls": FileFormatNum = 56: FileFormatType = "xlExcel8"<o:p></o:p>
End With<o:p></o:p>
Then to save the file <o:p></o:p>
<o:p> </o:p>
'Save as Tab Name to specified folder<o:p></o:p>
ActiveWorkbook.SaveAs Filename:=Range("u1") & Range("u2").Value & sheetName & ".xls"<o:p></o:p>
<o:p></o:p>
With ActiveWorkbook<o:p></o:p>
FileExtStr = ".xls": FileFormatNum = 56: FileFormatType = "xlExcel8"<o:p></o:p>
End With<o:p></o:p>
<o:p> </o:p>
I’ve tried replacing the FileFormatNum with -4143, and 52, and without the FileFormatType, but none of them make any difference. Without the “.xls” bit, it always reverts to saving as an .xlsx file. <o:p></o:p>
I’m working in Excel 2010, the file is an xlsm file, but I’ve also tried it with the initial file being a 97-2003 xls file, and I still can’t make it work.<o:p></o:p>
<o:p> </o:p>
My knowledge of code isn’t very good, Any help would be most appreciated! Thanks!! <o:p></o:p>
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi...

Only change in your code is to replace

FileExtStr = ".xls": FileFormatNum = 56: FileFormatType = "xlExcel8"<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

<o:p></o:p>with

FileFormat:=xlExcel8

Regards,

MGM
 
Upvote 0
Hi

The SaveAs method allows you to specify the FileFormat:

Code:
ActiveWorkbook.SaveAs "C:\Somefile.xls", FileFormat:=xlWorkbookNormal

EDIT: MGM's code is the one to use.
 
Upvote 0

Forum statistics

Threads
1,215,406
Messages
6,124,720
Members
449,184
Latest member
COrmerod

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