Locking(?) an excel session

K

Kiloran

While a long macro is running in Excel 2002 VBA, and a user opens another
Excel document on the PC, or opens an excel attachment in an email, I would
like to prevent these Excel documents opening in the same session/instance
as the one in which the macro is running, and start a new instance of Excel
if necessary.

Is there any way in VBA to control this?

--Kiloran
 
K

keepITcool

Just an idea.. but it seems to work :)

code must run in a class module..(which could be Thisworkbook
if the xlApp is instantiated then the event handler will create
a new instance.

Option Explicit

Dim WithEvents xlApp As Application

Sub LockAPP()
Set xlApp = New Application
End Sub


Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
Dim newApp As Object
Set newApp = CreateObject("Excel.Application")
newApp.Workbooks.Open Wb.FullName
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Kiloran wrote :
 
T

Tom Ogilvy

In tools=>Options in the general tab, select Ignore Other applications.

Application.IgnoreRemoteRequests = True

in VBA
 
K

Kiloran

Brilliant! Just what I needed.

Many thanks Tom, you have an enviable knowledge of VBA

--Kiloran
 
Top