Closing workbooks from other workbook

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone,

We have an hourly reservation calendar where users reserve slots of time for their use of the corresponding conference room. Playing with fire, I always considered that two users going in at the same time was a rare event, so data contention and losses could be avoided. Wrong. A couple of last saves obliterated the reservation of the other users.
To avoid that, I am attempting a workbook containing a user form in which call buttons can be actioned to do the following:
1) If the Reservation file being called is in use, then a message advises the user to wait a few and try again.
2) If it is not in use, the Reservation file is instantiated.
The problem is how to safely close the calling workbook from within the open Reservation file, without upsetting the session.
This closure should be at the very beginning of the initialization code, prior to the user executing his reservation.
I tried the Workbooks.close statement but depending where it is positioned in the Workbooks_Open macro it does weird things, like stop the execution of the Reservation file, occasional catastrophic failures, etc.
Any suggestions will be very appreciated.
Chuck
PS: This is the Reservation Open macro:
<code/>
Private Sub Workbook_Open()
Application.EnableCancelKey = xlDisabled
Application.WindowState = xlMaximized
Sheets(MonthName(Month(Date))).Activate
Application.ScreenUpdating = False
Application.Goto Sheets(MonthName(Month(Date))).Range("A6"), True
Dim c As Integer
Dim r As Integer
Call UnprotectMonth
For c = 4 To 12 Step 2
For r = 10 To 46 Step 9
If Cells(r, c) = Day(Now) Then
Cells(r, c).Font.Color = RGB(255, 0, 0)
Else
Debug.Print Cells(r, c).Address
Cells(r, c).Font.Color = RGB(0, 0, 0)
End If
Next r
Next c
Call Initializer
Application.ScreenUpdating = True
Call ProtectMonth
End Sub
</Code>
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top