Solved: excel 2007 saving to 97-2003 compatible
Thanks in advance to all the help you folks have given to get this far.
My office has 24 trainers that use this file we put together and they are blown away. They wonder why I still work there and don't run an excell business.
If it wasn't for this forum, I would be no where near that possibility.
Now for my new test.
Excell 2007 lets me save as a macro enbled format which works great if you use the 2007 version. Most of my co-workers are 2003 and aren't planning to upgrade soon. So I can export as 97-2003 compatible. For the most part that is ok, but I like to work in the 2007 version for the features.
One macro I run lets the user save a file that deletes several sheets and pulls a name from a named range (with .xls extension).
On my version (in .xlsm) clicking this macro uses the save as and adds the .xls to an .xlsm file. When reopenning this causes problems.
And if this is openned on the older version (2003) it looks like greek code.
I know I can change the output extension to .xlsm, but the other users wont ever see or use that version.
Is there a way to test what version excell is in use (2002,2003,2007) and the format of the working file (.xls, .xlsm), and save as can keep the correct format based on what is in use?
ie If I open in .xlsm the save as will use .xlsm - 2007 compatible
If I open in .xls the save as will use .xls 93-2003 compatible
I am having to work in compatiblity mode and making sure I have saved the right format when working with other offices is leaving room for error.
any suggestions would greatly be appreciated
Thanks again for your continued support.
I'll attach the file so you can see all I've (we've) done
it's office 7 xlsm zipped
Mark
Putting the reuslt into the saved type name
Ken,
I tweaked you suggestion to add on xld's ideas.
Your code says #Value! error
I also tried xld's adding your list in and seems to list the format ok.
Question is,
how do I tie in the result to the save as?
This is how I altered youre code:
[vba]Private Function GetFileSaveAsType(sExtension As String) As Long
Dim lSaveAsFormat As Long
lSaveAsFormat = GetFileSaveAsType(Right(ActiveWorkbook.FullName, 4))
Select Case LCase(sExtension)
'// Template Files
Case Is = ".xlt"
'17 Template
GetFileSaveAsType = xlTemplate
Case Is = "xlts"
'54 Open XML Template
GetFileSaveAsType = xlOpenXMLTemplate
Case Is = "xltm"
'53 Open XML Template Macro Enabled
GetFileSaveAsType = xlOpenXMLTemplateMacroEnabled
'// Workbooks
Case Is = ".xls"
'-4143 Workbook normal
GetFileSaveAsType = xlWorkbookNormal
Case Is = "xlsx"
'51 Open XML Workbook
GetFileSaveAsType = xlOpenXMLWorkbook
Case Is = "xlsm"
'52 Open XML Workbook Macro Enabled
GetFileSaveAsType = xlOpenXMLWorkbookMacroEnabled
'// Add-ins
Case Is = ".xla"
'18 Microsoft Excel 97-2003 Add-In
GetFileSaveAsType = xlAddIn8
Case Is = "xlam"
'55 Open XML Add-In
GetFileSaveAsType = xlOpenXMLAddIn
'// If in doubt...
Case Else
'-4143 Workbook normal
GetFileSaveAsType = xlWorkbookNormal
End Select
End Function[/vba]
This how I altered XLD's
[vba]Function FileSavedIn()
Select Case ActiveWorkbook.FileFormat
Case 56: FileSavedIn = "Excel 2003" '.xls?
Case 55: FileSavedIn = "Excel 2007 Open XML Add-in" '.xlam
Case 54: FileSavedIn = "Excel 2007 Open XML Template" '.xlts
Case 53: FileSavedIn = "Excel 2007 Open XML Template Macro Enabled" '.xltm
Case 52: FileSavedIn = "Excel 2007 Open XML Macros Enabled" ' .xlsm
Case 51: FileSavedIn = "Excel 2007 Open XML" ' .xlsx
Case -4143: FileSavedIn = "Excel 2000 et plus" ' (workbook normal) .xls
Case 43: FileSavedIn = "Excel 97/2000" ' .xls?
Case 39: FileSavedIn = "Excel 5" ' .xls?
Case 35: FileSavedIn = "Workbook Excel 4" ' .xls?
Case 33: FileSavedIn = "Sheet Excel 4" ' .xls?
Case 29: FileSavedIn = "Excel 3" ' .xls?
Case 18: FileSavedIn = "Excel 97-2003 Add-in" ' .xla
Case 17: FileSavedIn = "Excel Template" ' .xlt
Case 16: FileSavedIn = "Excel 2.1" ' .xls?
Case Else: FileSavedIn = "Unknown"
End Select
End Function
[/vba]
This is my code to save as:
[vba]sFileName = Application.GetSaveAsFilename(InitialFileName:=Range("trnqcName"))
If sFileName = "False" Then
End If
ThisWorkbook.SaveAs sFileName[/vba]