Problem: Closing one book causes the 2nd book freeze

F

fred

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top