Evertonx
08-05-2014, 11:13 AM
Hello,
need some help
I need the worksheet is saved with the name that is in cell A1
The following macro can accomplish what I need, but I need to call this macro automatically when I save by doing the following path File -> Save As ...
When I click File -> Save As, the macro runs, opens a dialog box with the text in cell A1, (is what I need), but after save, opens another dialog box to save again.
I want to save only 1x.
This Workbook
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call SaveAS
End Sub
Module
Sub SaveAS()
Dim fname
ChDrive (Left(ThisWorkbook.Path, 1))
ChDir ThisWorkbook.Path
reference = Range("A1").Value & " " & "-" & " " & Format(Now, "dd-mm-yyyy-hhmmss")
fname = Application.GetSaveAsFilename(reference, FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Save As")
If fname = False Then Exit Sub
ActiveWorkbook.SaveAs Filename:=fname
End Sub
need some help
I need the worksheet is saved with the name that is in cell A1
The following macro can accomplish what I need, but I need to call this macro automatically when I save by doing the following path File -> Save As ...
When I click File -> Save As, the macro runs, opens a dialog box with the text in cell A1, (is what I need), but after save, opens another dialog box to save again.
I want to save only 1x.
This Workbook
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call SaveAS
End Sub
Module
Sub SaveAS()
Dim fname
ChDrive (Left(ThisWorkbook.Path, 1))
ChDir ThisWorkbook.Path
reference = Range("A1").Value & " " & "-" & " " & Format(Now, "dd-mm-yyyy-hhmmss")
fname = Application.GetSaveAsFilename(reference, FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Save As")
If fname = False Then Exit Sub
ActiveWorkbook.SaveAs Filename:=fname
End Sub