The following VBA-code seems to be Excel-2007-proof !
Sub FileSaveXL2007()
Dim FName As Variant
Dim FileFormatValue As Long
'STEL EXCEL-VERSIE VAST
If Val(Application.Version) < 12 Then
'Using Excel97-2003
FName = Application.GetSaveAsFilename(InitialFileName:="", _
FileFilter:=" Excel 2000-2003 Workbook (*.xls),
*.xls,", _
FilterIndex:=2, Title:="Save File in Excelversion")
FileFormatValue = -4143
Else
'The option which Excel-2007 proof is
FName = Application.GetSaveAsFilename(InitialFileName:="", _
FileFilter:=" Excel Macro Free Workbook (*.xlsx),
*.xlsx," & _
" Excel Macro Enabled Workbook
(*.xlsm), *.xlsm," & _
" Excel 2000-2003 Workbook (*.xls),
*.xls," & _
" Excel Binary Workbook (*.xlsb),
*.xlsb", _
FilterIndex:=2, Title:="Save File in Excelversion")
If FName < False Then
Select Case LCase(Right(FName, Len(FName) - InStrRev(FName, ".",
, 1)))
Case "xls": FileFormatValue = 56
Case "xlsx": FileFormatValue = 51
Case "xlsm": FileFormatValue = 52
Case "xlsb": FileFormatValue = 50
Case Else: FileFormatValue = 0
End Select
'Save the File in the Version which belongs to the chosen extension
If FileFormatValue = 0 Then
MsgBox "Sorry, this is an unknown File Format"
Else
ActiveWorkbook.SaveAs FName, _
FileFormat:=FileFormatValue, CreateBackup:=False
End If
End If
End If
End Sub
With lot of thanks to the Excel-experts, going around on the internet.
Guus
"Jerry Khann" wrote:
Hello
"Guus" a écrit dans le message de news:
...
Excuse me....
Your suggestion, I cannot get it working.
IS there no solution like
Application.Dialogs(xlDialogSaveAs).Show ?
MyFileName = "MyFile.xlsx" ' Or a result of an expression like a
question to the user
BackState = Application.Dialogs(xlDialogSaveAs).Show(MyFileNam e ,
xlWorkbookDefault)
If etat = True Then
MsgBox ActiveWorkbook.FullName & " has been saved."
End If
Regards
--
Jerry Khann
Adresse invalide: retirer le bouchon _O_ et .invalid