Private Sub SaveSheet2File()
' XlFileFormat = xlExcel8 <===> File Extension = "xls" : Value = 56
' XlFileFormat = xlOpenXMLWorkbook <===> File Extension = "xlsx" : Value = 51
' XlFileFormat = xlExcel12 <===> File Extension = "xlsb" : Value = 50
' XlFileFormat = xlOpenXMLWorkbookMacroEnabled <===> File Extension = "xlsm" : Value = 52
Dim wks As Object, FileFormat As Long, index As Long
Dim FileName As String, szSaved As String, strPath As String, strName As String
On Error Resume Next
Application.ScreenUpdating = False
Set wks = ActiveWindow.SelectedSheets
index = GetSetting("Sheets2Files", "Settings", "FileType", 0)
strPath = GetSetting("Sheets2Files", "Settings", "Path", "")
strName = GetSetting("Sheets2Files", "Settings", "FileName", "")
Select Case index
Case Is = 1: FileFormat = 51
Case Is = 2: FileFormat = 52
Case Is = 3: FileFormat = 50
Case Is = 4: FileFormat = 56
End Select
If Len(strPath) * Len(strName) Then
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
If FileFormat > 0 Then
FileName = strPath & strName
szSaved = modSaveSheets.SaveSheets(wks, FileName, FileFormat, True)
If Len(szSaved) Then MsgBox "File """ & szSaved & """ have been successfully saved!"
Else
MsgBox "Please select a file type", , "WARNING!"
End If
Else
MsgBox "Please setup the path and file name:" & vbLf & _
"- Press 'Browse' button or type the path in 'Save to' Edit Box" & vbLf & _
"- Type the file name in 'File Name' Edit Box", , "WARNING!"
End If
Application.ScreenUpdating = True
End Sub