SaveAs Method with both 2003 & 2007

Citizen Dick

New Member
Joined
May 11, 2011
Messages
2
I need to come up with an IF statement for the version of Excel that is being utilized. I have some sites using Excel 2003 and others using Excel 2007 and I want to have my macro rename and save a document with a different name that I have in code but I don't know how to capture the version to add the right extension.
The macro that saves the workbook according to the value of a cell range works fine. It's just if someone has Excel 2003, they get an error message.
Here's a snippet of the code that I thought would save as a .xls or macro-enabled (.xlsm) file, but to no avail.
'Distinguishes the end user's version of Excel being used and will format and save as the parent workbook's file format.
If Application.Version = "11.0" Then
ActiveWorkbook.SaveAs Filename:= _
"Business Card Information Request - " & Range("Name").Value & ".xls", FileFormat _
:=56, CreateBackup:=False
ElseIf Application.Version = "12.0" Then
ActiveWorkbook.SaveAs Filename:= _
"Business Card Information Request - " & Range("Name").Value & ".xlsm", FileFormat _
:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If

Any help? Thanks.

My apologies if this has already been posted.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try

Code:
ElseIf Application.Version = "12.0" Then

    ActiveWorkbook.SaveAs Filename:= _
    "Business Card Information Request - " & Range("Name").Value & ".xlsm", FileFormat:=52, CreateBackup:=False

End If
 
Upvote 0
Try

Code:
ElseIf Application.Version = "12.0" Then

    ActiveWorkbook.SaveAs Filename:= _
    "Business Card Information Request - " & Range("Name").Value & ".xlsm", FileFormat:=52, CreateBackup:=False

End If

Unfortunately, that didn't work. Same error. Thanks for the suggestion.
Run -time error '1004':
Method 'SaveAs' of object'_Workbook' failed

 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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