Python COM vs Visual Basic COM

K

Kendall Dugger

I have to use an ultra simple call to a couple of
WordPerfect COM functions.

This works in Visual Basic as follows:

Dim objWP As Variant
Dim DocSumString As Variant
Set objWP = CreateObject("WordPerfect.PerfectScript")
objWP.FileOpen "c:\zebra.wpd", 1
DocSumString = objWP.DocSumGet(18)
Me!Text1 = DocSumString

This opens a WordPerfect file and grabs the 'Descriptive
Type' field from the document summary as a string. Pretty
simple.

Here is almost Identical Python Code:

import win32com.client
objWP =
win32com.client.Dispatch("WordPerfect.PerfectScript")
objWP.FileOpen("c:\\zebra.wpd", 1)
DocSumString = objWP.DocSumGet(18)


When I run it it gives me the following error:

Traceback (most recent call last):
File "C:/python_code/getdescriptivetype.py", line 3, in
-toplevel-
objWP.FileOpen("c:\\zebra.wpd", 1)
File
"C:\PYTHON23\Lib\site-packages\win32com\client\dynamic.py",
line 484, in __getattr__
raise pythoncom.com_error, details
com_error: (-2147352567, 'Exception occurred.', (61704,
'WPWIN10', 'Internal application error.', None, 0, 0), None)

I am unable to decipher what this means and am at a loss for
what to try next.

I can write my application in Visual Basic if I have to, but
I would much rather use Python.

Any assistance will be greatly appreciated.

Thanks,

-Kendall
 
K

Kendall Dugger

Nope, I have tried r"c:\zebra.wpd" and also used the sys.os
module to test if the file "c:\\zebra.wpd" exists prior to
running the COM stuff.

Python recognizes that the file is there. It seems to be an
error with the COM calls themselves.

Thanks for the suggestion, but I'm still stumped.

It's really frustrating that it works flawlessly under VB,
but fails under Python with almost identical code.

-Kendall
 
P

Paul McGuire

Kendall Dugger said:
I have to use an ultra simple call to a couple of
WordPerfect COM functions.
<snip>

Try reposting on the win32 list at ActiveState. I think you will get a
quicker response.

-- Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top