Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50103

Work_BeforeClose Error... how can I fix this

$
0
0
Hi There,

I keep getting the Compile error with this code: Ambiguous name detected: Workbook_BeforeClose..

Is there a way to rearrange the code below so as to not repeat the Workbook before close function?

Code:

Private Sub Workbook_AfterSave(ByVal Success As Boolean)
    chgflag = "Y"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If chgflag <> "Y" Then
 MsgBox ("You are Closing this before Generating Your Target Docs")
End If
End Sub

Private Sub Workbook_Open()
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_BeforeClose()
Application.CellDragAndDrop = True
End Sub

Many thanks.

Viewing all articles
Browse latest Browse all 50103

Trending Articles