Our Service

Finding Other Instances of Excel in a Macro

Excel macros are a powerful tool for automating repetitive tasks and streamlining your workflow. However, sometimes you may need to find other instances of Excel that are running on your computer. This can be useful if you need to interact with another Excel workbook or if you want to close all instances of Excel before running your macro.

Using VBA to Find Other Instances of Excel

One way to find other instances of Excel is to use VBA code. The following code will loop through all running processes on your computer and check if the process name is “EXCEL.EXE”. If it is, the code will add the process ID to an array.

Dim xlApp As Excel.Application

Dim xlBook As Excel.Workbook

Dim xlBooks As Excel.Workbooks

Dim xlProcessIDs() As Long

Dim i As Long

ReDim xlProcessIDs(0)

For Each proc In GetObject(“winmgmts:”). _

ExecQuery(“select * from Win32_Process where name=’EXCEL.EXE'”)

ReDim Preserve xlProcessIDs(i)

xlProcessIDs(i) = proc.ProcessID

i = i + 1

Next proc

Once you have the process IDs of all running instances of Excel, you can use them to interact with other workbooks or close all instances of Excel. For example, the following code will activate the first workbook in the second instance of Excel:

Set xlApp = GetObject(, “Excel.Application.2”)

Set xlBooks = xlApp.Workbooks

Set xlBook = xlBooks(1)


Using Task Manager to Find Other Instances of Excel

If you don’t want to use VBA, you can also use Task Manager to find other instances of Excel. To do this, open Task Manager by pressing Ctrl+Shift+Esc. Then, click on the “Details” tab and look for any processes named “EXCEL.EXE”.

If you want to close all instances of Excel, you can right-click on each process and select “End task”. Alternatively, you can select all Excel processes by holding down the Ctrl key and clicking on each process, and then click the “End task” button.


Finding other instances of Excel can be useful when working with multiple workbooks or when you need to close all instances of Excel before running a macro. Whether you use VBA or Task Manager, it’s important to be aware of all running instances of Excel on your computer.


Did you find this article useful?

Share it with your friends or colleagues

About Aepoch Advisors

We are a boutique accounting and consulting firm servicing international businesses operating in China. We offers book keeping and business advisory service. We also help our clients select and implement SAAS business applications
Cloud technology significantly reduces cost foreign companies traditionally spent on tax compliance and ERP systems. Our cloud professionals can help with streamlining your management and controling structure, as well as advising you on how to reduce risks and maximize profits with software purposely built for Chinese business. Contact us today to learn more about our services.