Avoid to reopen a working Workbook

M

Marcelo

I have a program developed in VBA over EXCEL which does not have t
allow to open another session of itself, that is, if a user opens th
book that contains the program, and once opened, he or she (the user
tries to open the same book again, first of them (first sessio
Workbook) does not have to allow to open the second one, all thi
without disturbing the normal EXCEL operation with other EXCE
workbooks.

In other words, I want to allow the User to open the Workbook
financial.xls only once at a time. (avoid reopen)

Another explanation:

How do I restrict the user to open a workbook only one time until it i
closed?

Thanks

Marcelo
 
C

Chip Pearson

Marcelo,

I'm not entirely clear what your question is. Excel
automatically prevents the user from opening the same workbook
twice (Excel can't have two files with the same name open).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
M

Marcelo

Try thie:

Put a code in a WB and open it using the "recently opened files
shortcut list at the bottom of the File menu.

Something like this:
Private Sub Workbook_Open()
MsgBox IIf(Me.ReadOnly, "Hi, I'm ReadOnly", "Good Morning")
End Sub

Open this using File | Open, the macro does execute a 2nd time.

I would like to avoid that.

I want to avoid too the message taht arise when you try to open th
opened workbook again : "TestBook.xls is alredy open. If you continu
your data will be lost." or something like that (my Excel is i
Spanish).

Let me try to explain how my software works: I open my workbook,
main UserForm appear with Excel Minimized and Invisibl
(Excel.Application.Visible = False).
At this point, if the user try to run a new session of this workboo
the message above appear and let the user choose yes or not ( rerunnin
the workbook damaging the data on the sheets worked by the user at thi
time). I want is to avoid this, In other words, When the user try t
run a new session of the workbook, nothing happend and the origina
session remain intact.

Thanks a lot.

Marcel
 
Top