Mailing List Archive

win32com.client -- beginner question
Hello,

I ' ll try to use the comclient ability of python. In the Doku I have
found
the example:

o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"

Because I have installed Excel95 I have given it a try and that's the
result:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import win32com.client
>>> o= win32com.client.Dispatch("Excel.Application")
>>> o.Workbooks.Add()
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "E:\Programme\Python\win32com\client\dynamic.py", line 400, in
__getattr_
_
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: Excel.Application.Workbooks

But Workbooks.Add is a available method as I can test with VBScript.
Is my installation corrupt or do I do some silly mistake or perhaps some
more serious?

Thanks for any answer.
Regards,
Axel
win32com.client -- beginner question [ In reply to ]
From: Axel Schmitz-Tewes <uzs59g@uni-bonn.de>

Hello,

I ' ll try to use the comclient ability of python. In the Doku I have
found
the example:

o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"

Because I have installed Excel95 I have given it a try and that's the
result:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import win32com.client
>>> o= win32com.client.Dispatch("Excel.Application")
>>> o.Workbooks.Add()
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "E:\Programme\Python\win32com\client\dynamic.py", line 400, in
__getattr_
_
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: Excel.Application.Workbooks

But Workbooks.Add is a available method as I can test with VBScript.
Is my installation corrupt or do I do some silly mistake or perhaps some
more serious?

Thanks for any answer.
Regards,
Axel
win32com.client -- beginner question [ In reply to ]
On Wed, 30 Jun 1999 08:43:06 +0200, Axel Schmitz-Tewes
<uzs59g@uni-bonn.de> wrote:

>Hello,
>
>I ' ll try to use the comclient ability of python. In the Doku I have
>found
>the example:
>
>o = win32com.client.Dispatch("Excel.Application")
>o.Visible = 1
>o.Workbooks.Add() # for office 97 – 95 a bit different!
>o.Cells(1,1).Value = "Hello"
>
>Because I have installed Excel95 I have given it a try and that's the
>result:
>
>Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> import win32com.client
>>>> o= win32com.client.Dispatch("Excel.Application")
>>>> o.Workbooks.Add()
>Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "E:\Programme\Python\win32com\client\dynamic.py", line 400, in
>__getattr_
>_
> raise AttributeError, "%s.%s" % (self._username_, attr)
>AttributeError: Excel.Application.Workbooks
>
>But Workbooks.Add is a available method as I can test with VBScript.
>Is my installation corrupt or do I do some silly mistake or perhaps some
>more serious?

Did you remember to run the makepy.py script in
Python\win32com\client? You need to run that one, select the COM
interface you want to use, e. g. "Microsoft Excel 5.0 Object Library
(1.0)" (or similar). makepy.py then generates the necessary Python
definitions, in a file in the Python\win32com\gen_py directory (named
according to the COM interface's GUID.

After that you should be able to access Excel without too much
trouble.

There's a introduction to the Win32COM stuff, which includes a brief
description of makepy.py, in the QuickStartClientCom.html file
included in the Win32COM installation.


-- Mikael
win32com.client -- beginner question [ In reply to ]
From: mikael@toolwood.com (Mikael Lyngvig)

On Wed, 30 Jun 1999 08:43:06 +0200, Axel Schmitz-Tewes
<uzs59g@uni-bonn.de> wrote:

>Hello,
>
>I ' ll try to use the comclient ability of python. In the Doku I have
>found
>the example:
>
>o = win32com.client.Dispatch("Excel.Application")
>o.Visible = 1
>o.Workbooks.Add() # for office 97 – 95 a bit different!
>o.Cells(1,1).Value = "Hello"
>
>Because I have installed Excel95 I have given it a try and that's the
>result:
>
>Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> import win32com.client
>>>> o= win32com.client.Dispatch("Excel.Application")
>>>> o.Workbooks.Add()
>Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "E:\Programme\Python\win32com\client\dynamic.py", line 400, in
>__getattr_
>_
> raise AttributeError, "%s.%s" % (self._username_, attr)
>AttributeError: Excel.Application.Workbooks
>
>But Workbooks.Add is a available method as I can test with VBScript.
>Is my installation corrupt or do I do some silly mistake or perhaps some
>more serious?

Did you remember to run the makepy.py script in
Python\win32com\client? You need to run that one, select the COM
interface you want to use, e. g. "Microsoft Excel 5.0 Object Library
(1.0)" (or similar). makepy.py then generates the necessary Python
definitions, in a file in the Python\win32com\gen_py directory (named
according to the COM interface's GUID.

After that you should be able to access Excel without too much
trouble.

There's a introduction to the Win32COM stuff, which includes a brief
description of makepy.py, in the QuickStartClientCom.html file
included in the Win32COM installation.


-- Mikael