Locked out of one spreadsheet while another sheets code is running

GiraffetheGeek

Board Regular
Joined
May 25, 2011
Messages
58
Hi guys and gals,

I work for a large organisation and as I am the only "geek" in my sub-organisation and regional area some of the more "geek" orientated tasks get assigned to me.

I am currently designing a sort of "menu" system using a shared excel worksheet that has buttons it it that will open other un-shared workbooks at act as an appointment schedule.

What I am trying to acheive is a shared workbook that everyone can have open and when they click one of the buttons it opens the other workbook. At this point I want the code on the first workbook to halt or wait, until the user has finished booking an appointment in the second workbook and then once it detects or sees that the second workbook is closed then continue running the remaining code.

I am not a systems enginner or administrator, but I can explain the structure of the network as best I can.

There are a number of different shared drives for each office that can be accessed by any office across the country. Users "My Documents" follow them wherever they log in so I assume this data is stored centrally somewhere.

I know how to reference each shared drives location. In the code below I have it access information on my users data and once I have it working I will change it to a shared drive location.

In the \\corp.xxx.yyyy.nz the xxx and yyyy are actually some other values but I need to keep the organisation anonymous in this forum.

My code is this:
Rich (BB code):
Public OpenIndicator As Integer
Dim wBook As Workbook
 
Sub OpenAppointmentsOne()
    Btn_ScheduleOne.Visible = False
    Workbooks.Open FileName:="\\corp.xxx.yyyy.nz\usersg\gcarr009\Documents\IT\Site\Appt.xls"
5   Application.Wait Now + TimeValue("00:00:30")
    Call TestIfOpen
    If OpenIndicator = 1 Then
        GoTo 5
    End If
    Btn_ScheduleOne.Visible = True
    ActiveWorkbook.Save
End Sub
 
Sub TestIfOpen()
Dim wb As Workbook
For Each wb In Workbooks
    If wb.Name = "Appt.xls" Then
        OpenIndicator = 1
        Exit Sub
    End If
Next
OpenIndicator = 0
End Sub

Most of this works fine EXCEPT that in the 30 seconds wait while the code is waiting to check the status of the second sheet again the user cannot manipulate (add data, change data, save or close workbook) any of the other worksheets so it just endlessly loops until I ctrl+break it.

Anyone know how I can get around this issue - or code differently to reach my particular goal?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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