Excel Automation Application is shared with interactive?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a VBScript that is creating an Excel.Application object and writing to
workbooks\worksheets in the background. This operation takes hours to
complete and if I open a spreadsheet to do other work while my script is
running, this other workbook opens in the application window my script
created. This causes my script to fail when it attempts to control the
Application object. How can I prevent any other interaction with the
Application object my script creates? I want to automatically open a new
Application window when I manually open a workbook. Hope this makes sense
and someone can tell me how to fix this. Thanks.
 
Hi Huey,

Try Hiding the instance of Excel:

'=============>>
Public Sub Tester()
Dim oApp As Object
Dim oWB As Object

Set oApp = CreateObject("Excel.Application")
Set oWB = oApp.Workbooks.Open("C:\MyBook.xls")
oApp.Visible = False

'Your code

End Sub
'<<=============
 
Norman, It is hidden to begin with. But it becomes visible when I manually
open a different workbook. What I am hoping for is some setting in the Excel
application object that will make it "private" so that no other processes can
interact with it.
 
Hi Huey,

'-----------------
Norman, It is hidden to begin with. But it becomes visible when I manually
open a different workbook. What I am hoping for is some setting in the
Excel
application object that will make it "private" so that no other processes
can
interact with it.
'-----------------

How did you open a workbook manually in a hidden
instance of Excel?
 
That's what I want to know. All I do is double-click on a spreadsheet either
from a file browser or as an attachement from an email and it pops up in the
application object that my script created.

I did find that there is an Application.Interactive property I could set to
False but the Help information reads like this only disables input from the
user and so I might just hose myself if I set this to False in my script.
I'm at home now so I can't easily try this on my script so I'll check back in
tomorrow.
 
I found that others have been able to do what I want by using this :

Application.IgnoreRemoteRequests = True

This will stop any new workbooks from opening in the Application object
referred to in the above code.

I thank you. ;]
 
Yes, that will refuse DDE requests, like those from Explorer etc., so WBs
will open in another instance of Excel.
Your instance is not immune from interaction with COM, but someone/some app
would (normally) have to go looking for your instance, although GetObject
could return it.

NickHK

Huey said:
I found that others have been able to do what I want by using this :

Application.IgnoreRemoteRequests = True

This will stop any new workbooks from opening in the Application object
referred to in the above code.

I thank you. ;]

Huey said:
That's what I want to know. All I do is double-click on a spreadsheet either
from a file browser or as an attachement from an email and it pops up in the
application object that my script created.

I did find that there is an Application.Interactive property I could set to
False but the Help information reads like this only disables input from the
user and so I might just hose myself if I set this to False in my script.
I'm at home now so I can't easily try this on my script so I'll check back in
tomorrow.
 
Back
Top