Chip, I solved it

R

Roberto

Hi
You may remember I had a before_close problem in that when
opening another workbook the original workbook remained
open? And if I put a thisworkbook.close in, then it made
the message box appear twice.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Do you want to open Data2", vbYesNo) = vbYes
Then
Workbooks.Open "C:\Windows\Desktop\Data2.xls"
end if

However I solved the above problem by using an idea from
another post.

Public CloseMe

Private Sub Workbook_Open()
CloseMe = False
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Select Case CloseMe
Case False
CloseMe = True
If MsgBox("Do you want to open Data2", vbYesNo) = vbYes
Then
Workbooks.Open "C:\Windows\Desktop\Data2.xls"
ThisWorkbook.Close
Else
CloseMe = True
Application.Quit
End If
End Select
End Sub

Cheers
Roberto
 

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