×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

One process, many Instances. How to identify them

One process, many Instances. How to identify them

One process, many Instances. How to identify them

(OP)
Hi, I am trying to solve an issue but I do not know how. Sorry for my english.
On a computer, Excel is automatically launched by some script and this can happen more than one time.
So I can have two o three files opened by excel in the same moment.
I have to quit only one determinated instance of excel and not all of the open ones.
I know how to quit excel but this closes all the instances and all the files.
In the process list I see always only one excel instance and I do not know how to identify better than I do.
Thank you in advance for you help
Luca

RE: One process, many Instances. How to identify them

Hi,

What you appear to have is ONE instance of the Excel Application Object within which is contained multiple instances of Excel Workbook Objects.

So what you need to do is to Close the Workbooks you do not want.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: One process, many Instances. How to identify them

(OP)
Hi, yes I have to close only one between the workbooks, but how with vbscript?
Thank you

RE: One process, many Instances. How to identify them

Please post the code you are currently using for this process.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: One process, many Instances. How to identify them

(OP)
This is the code I actually use.


Function fctExcelKiller()
sQuery = "SELECT * FROM Win32_Process WHERE Name LIKE '%Excel.exe%'"
Set objItems = objWMIService.ExecQuery(sQuery)
For Each objItem In objItems
objItem.Terminate
Next
End Function

RE: One process, many Instances. How to identify them

CODE

'
   Function fctExcelKiller()
   sQuery = "SELECT * FROM Win32_Process WHERE Name LIKE '%Excel.exe%'"
   Set objItems = objWMIService.ExecQuery(sQuery)

   With objItem In objItems
       For i = 2 To .Count
           .Workbooks(i).Close
       Next
   End With
End Function 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: One process, many Instances. How to identify them

Erm ... I'd be s teeny bit surprised if WMI was returning a Excel COM object here ...

RE: One process, many Instances. How to identify them

Put a BREAK here

CODE

Function fctExcelKiller()
sQuery = "SELECT * FROM Win32_Process WHERE Name LIKE '%Excel.exe%'"
Set objItems = objWMIService.ExecQuery(sQuery)
For Each objItem In objItems
objItem.Terminate
Next
End Function 
Run your code to the BREAK, then Select objItems and open a Watch Window to inspect this object. Please report back your observations

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: One process, many Instances. How to identify them

(OP)
Thank you so much for your answers. I'm sorry SkipVought, I don't know what you mean when you say Watch Window, I am italian and the italian software names and their menu functions are a little bit different. I went in the internet looking for softwares with Watch Window, Maybe I could find it in Microsoft Script Debugger or anything else?
Meanwhile I am trying with the workbooks names to choose between the open excel sheets. I will go on tomorrow with some other test to understand if it could be enough. Thank you again. Luca

RE: One process, many Instances. How to identify them

A break? A watch window? With vbscript?

RE: One process, many Instances. How to identify them

Oopsblush

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close