Clyde38
Electrical
- Oct 31, 2003
- 533
I have included an automatic save subroutine using the Private Sub Workbook_BeforSave.... funciton in the VBA editor. I am using it to save to a particular path and file name. This works fine until I add a new worksheet to the workbook. All other additions or changes to the existing workbook will save automatically when I save the the workbook. What's up? See below..
I do not do many VBA programs. This is a variation of an Excel tip that I read.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim rngPullName As Range
Dim strSavePath As String
Application.DisplayAlerts = False
Set rngPullName = ThisWorkbook.Sheets(5).Range("A4")
strSavePath = "C:\Spreadsheets\myfilename\"
ActiveWorkbook.SaveAs Filename:=strSavePath & rngPullName & ".xls"
If ThisWorkbook.Saved = True Then
Cancel = True
End If
Application.DisplayAlerts = True
End Sub
I do not do many VBA programs. This is a variation of an Excel tip that I read.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim rngPullName As Range
Dim strSavePath As String
Application.DisplayAlerts = False
Set rngPullName = ThisWorkbook.Sheets(5).Range("A4")
strSavePath = "C:\Spreadsheets\myfilename\"
ActiveWorkbook.SaveAs Filename:=strSavePath & rngPullName & ".xls"
If ThisWorkbook.Saved = True Then
Cancel = True
End If
Application.DisplayAlerts = True
End Sub