Save Excel Workbook Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a button which saves a workbook as a specified name. The code
is as follows:

Private Sub CommandButton1_Click()

Dim sFileName As Variant

With Application.Dialogs(xlDialogSaveAs)
.Show ("CurrentVersion")

End With

End Sub

What do I need to do to save the file automatically as a value in Cell A1,
instead of "CurrentVersion" and without having "SAVE AS" Dialogue Box
displaying?
 
Try this:

Private Sub CommandButton1_Click()

Dim sFileName As Variant
sFileName = Worksheets("Sheet1").Range("A1")
'sFileName needs to include the path
'you can add it if necessary with the following
sFileName = "C:\temp\" & sFileName

ActiveWorkbook.SaveAs (sFileName)

End Sub
 
Back
Top