Convert xlsx to xls in VBA (1 Viewer)

marlan

Registered User.
Local time
Today, 16:52
Joined
Jan 19, 2010
Messages
409
Hi,
I am running Office 2003 (in Access).
I need to convert a xlsx file to xls, this is my code:
Code:
ApXL.Workbooks.Open (strFilePath)
ApXL is my Excel Application Object, and I have it open an Excel 2007/2010 file. It opens do to compatibility pack I've instailled.
based on this I wrote this code:
Code:
        ApXL.Application.DisplayAlerts = False
        ApXL.Application.ActiveWorkbook.CheckCompatibility = False
        ApXL.Application.ActiveWorkbook.SaveAs FileName:=newFileName, FileFormat:=xlExcel8
        ApXL.Application.ActiveWorkbook.Close
        ApXL.Application.DisplayAlerts = True
newFileName has a "xls" extention.
I result with a file formatted id 2007/2010, with xls extension.

Where am I going wrong?

TIA
 
Last edited:

jscranton

New member
Local time
Today, 09:52
Joined
Jan 15, 2013
Messages
3
What if you replace this:

FileFormat:=xlExcel8

With this:

FileFormatNum = -4143

I know from another piece of code I wrote that I had better success with a similar operation using FileFormatNum. For the earlier version of excel (Val(Application.Version) < 12), that is the .xls format number.
 

marlan

Registered User.
Local time
Today, 16:52
Joined
Jan 19, 2010
Messages
409
Hi, and Thanks for your reply,
Just tryed it, tryed 56 before, the sam results.
 

marlan

Registered User.
Local time
Today, 16:52
Joined
Jan 19, 2010
Messages
409
BTW, could you please point me to where FileFormatNum = -4143 is for xls files?
 

marlan

Registered User.
Local time
Today, 16:52
Joined
Jan 19, 2010
Messages
409
OK, this is the line of code:
Code:
ApXL.Application.ActiveWorkbook.SaveAs myFileName, FileFormat:=56

But: Won't work in 2003 enviroment, only in 2007.

If anyone knows otherwize, I'd be glad to hear.

All the best!
 

marlan

Registered User.
Local time
Today, 16:52
Joined
Jan 19, 2010
Messages
409
Resolved here, using FileFormat:= -4143 for Acc2003, and 56 for Acc2007 and up.
 

Users who are viewing this thread

Top Bottom