3

I am trying to use COM / pywin32 to create an autonomous and invisible Excel process that is different from the one currently running.

If I use the code below while an Excel window is already open, it will make the former invisible. I presume this is because it just accesses the same process.

from win32com.client import Dispatch
excel =  Dispatch('Excel.Application')
excel.Visible = False
excel.WorkBooks.Open('C:/someFile.xls')

The reason I need this, is because I would like to scrape a different Excel file in the background without affecting the current work. Plus, I don't know how to only close one of the processes.

If you are going to suggest a new library, I would also like to know how to handle this in COM.

1 Answer 1

5
excel = win32.DispatchEx('Excel.Application')

also if you wan to manipulate excel files try

Sign up to request clarification or add additional context in comments.

1 Comment

Small warning about DispatchEx: while this does create a new Excel process, it doesn't guarantee that the process remains isolated. For example: if you open an excel file through windows explorer, it is still possible that this will reuse the process you opened with DispatchEx. AFAIK, there is no real way to prevent this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.