PDA

View Full Version : Save as xlsm function



pcm034
09-30-2012, 09:27 AM
I am very new to VBA and require some help with saving a backup file through a button function. Can someone point me in the right direction? I would like for the file to automatically save from a multiple cell values as the name. Here is the code that I have.

ElseIf Application.Caller = "SaveAsExcelButton" Then
Dim Fname As String
MsgBox "Where would you like to save the Excel Backup of this Quote"
Fname = Application.GetSaveAsFilename("", _
FileFilter:="Excel Filer (*.xlsm), *.xlsm", _
Title:="Save Quote Backup")
If Fname = False Then
MsgBox "You did not select a save location"
Else
ActiveWorkbook.SaveAs Filename:= _
Fname + ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If

Else
MsgBox "Not sure what happened"
End If

mikerickson
09-30-2012, 10:13 AM
Perhaps the built in SaveAs dialog would work for you
If Application.Dialogs(xlDialogSaveAs).Show(, , vbNullString) Then
MsgBox "saved"
Else
MsgBox "something happened"
End If

pcm034
09-30-2012, 10:18 AM
Thank you very much! It worked great!