Locking(?) an excel session

  • Thread starter Thread starter Kiloran
  • Start date Start date
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
 
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 :
 
In tools=>Options in the general tab, select Ignore Other applications.

Application.IgnoreRemoteRequests = True

in VBA
 
Brilliant! Just what I needed.

Many thanks Tom, you have an enviable knowledge of VBA

--Kiloran
 

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