View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Roberto[_4_] Roberto[_4_] is offline
external usenet poster
 
Posts: 3
Default Chip, I solved it

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