سؤال

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.

هل كانت مفيدة؟

المحلول

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

also if you wan to manipulate excel files try

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top