Create buttom that saves current file in a given filename (Excel)

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

Guest

I want the user to save a protected worksheet by clicking on an action
buttom. The file should be saved with another file name taken from a cell in
the worksheet.
 
mamealemka said:
I want the user to save a protected worksheet by clicking on an action
buttom. The file should be saved with another file name taken from a cell
in
the worksheet.
Hi,

try the following code:

Private Sub CommandButton1_Click()
Const MyPath = "C:\"

With ThisWorkbook
.SaveAs Filename:=MyPath & Cells(1, 2).Value & ".xls" '<===Cell B1 =>
Change
End With

End Sub

This code does not make a control on the path of your folder.

Thunder
 
Hi Thunder

Thanks.

Thunder said:
Hi,

try the following code:

Private Sub CommandButton1_Click()
Const MyPath = "C:\"

With ThisWorkbook
.SaveAs Filename:=MyPath & Cells(1, 2).Value & ".xls" '<===Cell B1 =>
Change
End With

End Sub

This code does not make a control on the path of your folder.

Thunder
 
Back
Top