Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create new Excel process with COM (pywin32)

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.

like image 826
TimY Avatar asked Jul 30 '26 13:07

TimY


1 Answers

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

also if you wan to manipulate excel files try

  • http://pythonhosted.org/openpyxl/
  • http://www.python-excel.org/
like image 157
yemu Avatar answered Aug 01 '26 02:08

yemu