When opening e.g. a spreadsheet with pywin32, I found two options to do so:
excel1 = win32com.client.DispatchEx('Excel.Application')
wb = excel1.Workbooks.Open('myxls.xls')
or I could do
excel2 = win32com.client.Dispatch('Excel.Application')
wb = excel2.Workbooks.Open('myxls.xls')
and I'm wondering if this makes any difference. The docstrings don't help me much either:
>>> w32.Dispatch.__doc__
'Creates a Dispatch based COM object.\n '
>>> w32.DispatchEx.__doc__
'Creates a Dispatch based COM object on a specific machine.\n '
In this site they suggest that DispatchEx
might be for remote access.
Does it make any difference which method I use when I'm simply trying to automate spreadsheets on my own PC?
It depends on what you want. If Excel is already open, using dispatch will create a new tab in the open Excel instance. If Excel is already open, using dispatchEx will open a new instance of Excel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With