JeffL
04-05-2013, 03:44 PM
One last (I hope) problem.
I want to be able to run my Excel app on an XP laptop using Office 2000, and my Win 8 desktop using Office 2013.
I have code in the macro to open a .CSV file, and close it as a .XLS file. The formats are different, which I thought I took care of with this code:
' Get the correct file format the version of Excel running
If Application.OperatingSystem = "Windows (32-bit) NT 5.01" Then
' For old Excel
ActiveWorkbook.SaveAs Filename:="C:\Jeff\Temp\StreetSmart.xls", FileFormat _
:=xlExcel9795, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Else
' For new Excel
ActiveWorkbook.SaveAs Filename:="C:\Jeff\Temp\StreetSmart.xls", FileFormat _
:=xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
End If
It works fine on the Win 8 computer, but the XP computer with the older Office 2000 doesn't like the variable xlExcel8. Even though it's not used on that computer, I get an error because it's not defined. It will run if I define it as a string, but then the Win 8 computer running Office 2013 gives me an error. I was hoping there was a way to set up my own variable for FileFormat:= but I haven't been able to come up with anything.
How can I make this work in both environments?
I want to be able to run my Excel app on an XP laptop using Office 2000, and my Win 8 desktop using Office 2013.
I have code in the macro to open a .CSV file, and close it as a .XLS file. The formats are different, which I thought I took care of with this code:
' Get the correct file format the version of Excel running
If Application.OperatingSystem = "Windows (32-bit) NT 5.01" Then
' For old Excel
ActiveWorkbook.SaveAs Filename:="C:\Jeff\Temp\StreetSmart.xls", FileFormat _
:=xlExcel9795, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Else
' For new Excel
ActiveWorkbook.SaveAs Filename:="C:\Jeff\Temp\StreetSmart.xls", FileFormat _
:=xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
End If
It works fine on the Win 8 computer, but the XP computer with the older Office 2000 doesn't like the variable xlExcel8. Even though it's not used on that computer, I get an error because it's not defined. It will run if I define it as a string, but then the Win 8 computer running Office 2013 gives me an error. I was hoping there was a way to set up my own variable for FileFormat:= but I haven't been able to come up with anything.
How can I make this work in both environments?