gnod
01-26-2008, 10:55 PM
Hi,
i need to patch or modify the procedure the mistake i made with my templates. how do i programmatically delete then replace the procedure of Workbook_BeforeClose(Cancel As Boolean) in the thisworkbook.. i need to change the templates in a closed workbook..
From this procedure
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim dtTestDate As Date
' If the test date is less than todays date, the file will not be saved
With Worksheets("Annual_EmpInfoSheet")
If .Range("Annual_HeaderData_BudgetYr") <> "" Then
dtTestDate = DateValue("1/15/" & .Range("Annual_HeaderData_BudgetYr"))
If dtTestDate < Date Then
MsgBox "Any changes you made will not be save. Annual Budget is already done."
Application.ThisWorkbook.Saved = True
Application.ThisWorkbook.Close
End If
End If
End With
End Sub
To this procedure
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim dtTestDate As Date
' If the test date is less than todays date, the file will not be saved
With Worksheets("Annual_EmpInfoSheet")
If .Range("Annual_HeaderData_BudgetYr") <> "" And Range("BudgetType").value = "Annual" Then 'Additional condition
dtTestDate = DateValue("1/15/" & .Range("Annual_HeaderData_BudgetYr"))
If dtTestDate < Date Then
MsgBox "Any changes you made will not be save. Annual Budget is already done."
Application.ThisWorkbook.Saved = True
Application.ThisWorkbook.Close
End If
End If
End With
Enable_SaveAndSaveAs ' Additional
End Sub
kindly assist..
:help
thanks..
i need to patch or modify the procedure the mistake i made with my templates. how do i programmatically delete then replace the procedure of Workbook_BeforeClose(Cancel As Boolean) in the thisworkbook.. i need to change the templates in a closed workbook..
From this procedure
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim dtTestDate As Date
' If the test date is less than todays date, the file will not be saved
With Worksheets("Annual_EmpInfoSheet")
If .Range("Annual_HeaderData_BudgetYr") <> "" Then
dtTestDate = DateValue("1/15/" & .Range("Annual_HeaderData_BudgetYr"))
If dtTestDate < Date Then
MsgBox "Any changes you made will not be save. Annual Budget is already done."
Application.ThisWorkbook.Saved = True
Application.ThisWorkbook.Close
End If
End If
End With
End Sub
To this procedure
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim dtTestDate As Date
' If the test date is less than todays date, the file will not be saved
With Worksheets("Annual_EmpInfoSheet")
If .Range("Annual_HeaderData_BudgetYr") <> "" And Range("BudgetType").value = "Annual" Then 'Additional condition
dtTestDate = DateValue("1/15/" & .Range("Annual_HeaderData_BudgetYr"))
If dtTestDate < Date Then
MsgBox "Any changes you made will not be save. Annual Budget is already done."
Application.ThisWorkbook.Saved = True
Application.ThisWorkbook.Close
End If
End If
End With
Enable_SaveAndSaveAs ' Additional
End Sub
kindly assist..
:help
thanks..