Benny
07-13-2002, 01:03 AM
Hey,
I was given a COM object in the form of a DLL.
I downloaded and install win32all package (which contains the win32com package).
I was then able to convert the DLL to a python module - I used this command:
C:\Documents and Settings\Ben Birnbaum>c:\Python\python.exe c:\Python\Lib\site-p
ackages\win32com\client\makepy.py d:\wordleaf\SWordCOM.dll > d:\wordleaf\SWordCO
M.py
Generating to C:\Python\lib\site-packages\win32com\gen_py\CA741864-5BBE-4083-83E
6-01865C006DADx0x1x0.py
So now I have a python module - the source of which can be viewed here:
http://www.marlolake.com.au/SWordCOM.py
The problem I've got is, Im having trouble using it........I was given this example VB code:
Private Sub Command1_Click()
Dim a As New SWORDCOMLib.WordComImp
Dim s As String
s = a.getDataFileName("c:\letter.doc")
MsgBox s
Call a.UpdateWordDataFileName("c:\letter.doc", "c:\letter.txt")
Set a = Nothing
End Sub
I cant get this working in Python:
>>> a = SWordCOM.WordComImp
>>> a
<class SWordCOM.WordComImp at 0x00FC9400>
>>> g = a.getDataFileName("c:\letter.doc")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
AttributeError: class WordComImp has no attribute 'getDataFileName'
or
>>> a = SWordCOM.IWordComImp
>>> s = a.GetDataFileName("c:\test.doc")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: unbound method GetDataFileName() must be called with IWordComImp instance as first argument (got str instance instead)
Im probably over looking something really simple here - but I've no idea.
Thanks....
I was given a COM object in the form of a DLL.
I downloaded and install win32all package (which contains the win32com package).
I was then able to convert the DLL to a python module - I used this command:
C:\Documents and Settings\Ben Birnbaum>c:\Python\python.exe c:\Python\Lib\site-p
ackages\win32com\client\makepy.py d:\wordleaf\SWordCOM.dll > d:\wordleaf\SWordCO
M.py
Generating to C:\Python\lib\site-packages\win32com\gen_py\CA741864-5BBE-4083-83E
6-01865C006DADx0x1x0.py
So now I have a python module - the source of which can be viewed here:
http://www.marlolake.com.au/SWordCOM.py
The problem I've got is, Im having trouble using it........I was given this example VB code:
Private Sub Command1_Click()
Dim a As New SWORDCOMLib.WordComImp
Dim s As String
s = a.getDataFileName("c:\letter.doc")
MsgBox s
Call a.UpdateWordDataFileName("c:\letter.doc", "c:\letter.txt")
Set a = Nothing
End Sub
I cant get this working in Python:
>>> a = SWordCOM.WordComImp
>>> a
<class SWordCOM.WordComImp at 0x00FC9400>
>>> g = a.getDataFileName("c:\letter.doc")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
AttributeError: class WordComImp has no attribute 'getDataFileName'
or
>>> a = SWordCOM.IWordComImp
>>> s = a.GetDataFileName("c:\test.doc")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: unbound method GetDataFileName() must be called with IWordComImp instance as first argument (got str instance instead)
Im probably over looking something really simple here - but I've no idea.
Thanks....