0

I am trying to open excel application using win32com. Everything I tried so far gives me attribute error.

So far I tried

win32com.client.Dispatch('Excel.Application')

win32com.client.DispatchEx('Excel Application')

win32com.client.gencache.EnsureDispatch('Excel.Application')

I also tried both pip install pywin32 and pypiwin32

Requirement already satisfied: pypiwin32 in c:\users\asa\appdata\local\programs\python\python37- 
32\lib\site-packages (223)

Requirement already satisfied: pywin32>=223 in 
c:\users\asa\appdata\local\programs\python\python37-32\lib\site-packages (from pypiwin32) (227)

Everything seems to be installed fine

Atiqul Islam
  • 83
  • 1
  • 1
  • 4
  • Can you post the attribute errors you get when trying to open Excel? Also try storing your Application object in a variable and pass it the .Visible = True, otherwise you wont see it open up when you get it to work. – tst Dec 03 '19 at 09:18
  • xl = win32com.client.gencache.EnsureDispatch('Excel.Application') xl.Visible = True – tst Dec 03 '19 at 09:18

1 Answers1

0

Well I don't know about win32com but you could also do it like this:

import os

os.system('start excel')

In fact, you can implement pretty much any command line input with os.system('[cmd input goes here]'), then you only have to google how to actually start excel from the command line.

Anteino
  • 1,044
  • 7
  • 28