An excel template file created in version 2003 has forms and macros in it. The file was distributed to users with 2003 and 2007. We need to make sure the 2007 users do a file, save as to the earlier version because Microsoft's converter fails on files with forms/macros in it (and the person who ultimately gets these files does not have version 2007).
If the user does the file, save as, it works fine. If I try to save the file using code I get an Error 1004 on the save as message.
Here's my code (stripped variable dec and error handling)
sRecommend = "Counseling"
If val(Application.version) < 12 then
'user is in Excel 97 through 2003
FileExtStr = ".xls"
FileformatNum = -4143
Else
'user is in 2007 or 2010 - need to save without the macros
FileExtStr = ".xls"
FileFormatNum = 56
End if
sPath = Application.GetSaveAsFileName(InitialFileRecommend:=sRecommend,_
FileFilter:="Excel Files(*.xls),".xls")
sFile = sPath
Activeworkbook.SaveAs Filename:=sFile, _
FileFormat:=FileFormatNum, _
Password="",WriteResPassword:="",ReadOnlyRecommended:=False, _
Create Backup:=False
End if
The code fails on the last statement - error 1004. Any thoughts?
Thanks in advance.
If the user does the file, save as, it works fine. If I try to save the file using code I get an Error 1004 on the save as message.
Here's my code (stripped variable dec and error handling)
sRecommend = "Counseling"
If val(Application.version) < 12 then
'user is in Excel 97 through 2003
FileExtStr = ".xls"
FileformatNum = -4143
Else
'user is in 2007 or 2010 - need to save without the macros
FileExtStr = ".xls"
FileFormatNum = 56
End if
sPath = Application.GetSaveAsFileName(InitialFileRecommend:=sRecommend,_
FileFilter:="Excel Files(*.xls),".xls")
sFile = sPath
Activeworkbook.SaveAs Filename:=sFile, _
FileFormat:=FileFormatNum, _
Password="",WriteResPassword:="",ReadOnlyRecommended:=False, _
Create Backup:=False
End if
The code fails on the last statement - error 1004. Any thoughts?
Thanks in advance.