ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save Excel Workbook Question (https://www.excelbanter.com/excel-programming/373959-save-excel-workbook-question.html)

yasser

Save Excel Workbook Question
 
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?


CraTaw

Save Excel Workbook Question
 
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


All times are GMT +1. The time now is 02:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com