Limiting number of users opening Excel Workbook at one time.

  • Thread starter Thread starter RickatMDG
  • Start date Start date
R

RickatMDG

We are trying to limit the number of users that are able to open and work on
an Excel Workbook at the same time to one at a time. Is there a way to
configure the sheets to do this?
 
tricky!
What you can try is to use a markerfile (with just one number, ie the number
of current users).
Look under help under "Write" and "Get" how to manage input files.
If you include some VB code in Workbook_Open and Workbook_BeforeClose then
you can use the markerfile as a counter.
Something like

Type Record ' Define user-defined type.
ID As Integer
Name As Integer
End Type

Dim MyRecord As Record, Position ' Declare variables.

' Open sample file for random access.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
' Read the sample file using the Get statement.
Position = 1 ' Define record number.
Get #1, Position, MyRecord ' Read third record.

'which will give the variable MyRecord the number in the file
'Now check
if MyRecord > 4 then
msgbox("to many users, file will autoclose")
application.close
end if

Write #1, MyRecord + 1

Close #1 ' Close file


in the Workbook_BeforeClose include a similar statement....
 

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

Back
Top