Problem: Closing one book causes the 2nd book freeze
Stupid me.
I should NOT use Wb.Close in that situation.
Thanks,
Fred
"fred" wrote in message
...
Hello,
My app is using Excel automation.
I have 2 workbooks opened.
When user wants to close one workbook my code catches that event asking
for the confirmation.
When permission granted then my app allows closing that workbook but after
the closing the remaining workbook remains frozen (does not respond to the
mouse click).
Minimizing and restoring Excel clears that problem.
What I am doing wrong?
Below is the code:
==============
Private Sub moExcelApp_WorkbookBeforeClose(ByVal Wb As Excel.Workbook,
Cancel As Boolean)
If Wb.Name = moExcelDNCWS.Parent.Name Then
If moExcelDNCWS Is Nothing Then Exit Sub
If MsgBox("Closing " & Wb.Name & " will disable DNC option." &
vbCrLf & "Do you really want to close it?", vbQuestion + vbYesNo,
App.Title) = vbYes Then
Set moExcelDNCWS = Nothing
Wb.Close
Else
Cancel = True
End If
End If
End Sub
|