ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Automation Application is shared with interactive? (https://www.excelbanter.com/excel-programming/390470-excel-automation-application-shared-interactive.html)

Huey

Excel Automation Application is shared with interactive?
 
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.

Norman Jones

Excel Automation Application is shared with interactive?
 
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
'<<=============


---
Regards,
Norman


"Huey" wrote in message
...
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.




Huey

Excel Automation Application is shared with interactive?
 
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.

"Norman Jones" wrote:

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
'<<=============


---
Regards,
Norman


"Huey" wrote in message
...
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.





Norman Jones

Excel Automation Application is shared with interactive?
 
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?


---
Regards,
Norman



Huey

Excel Automation Application is shared with interactive?
 
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.

"Norman Jones" wrote:

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?


---
Regards,
Norman




Huey

Excel Automation Application is shared with interactive?
 
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" wrote:

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.

"Norman Jones" wrote:

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?


---
Regards,
Norman




NickHK

Excel Automation Application is shared with interactive?
 
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" wrote in message
...
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" wrote:

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.

"Norman Jones" wrote:

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?


---
Regards,
Norman







All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com