473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

accessing Microsoft Works document through COM interface in Python

I am tryin to use Microsoft Works Wordprocessor from Python

After generating the .py module from the type library using makepy
utility, I runt he following commands,
from win32com.client import Dispatch
object = Dispatch("MicrosoftWorks.WordProcessor.AppControl" )
and I get the following error,
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\Lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userN ame,clsctx)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py",
line 91, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py",
line 79, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147467262, 'No such interface supported', None, None)

It seems like IDispatch is not implemented by Microsoft Works
WordProcessor.

The .py module generated from type library is below
# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.91
# By python version 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32
bit (Intel)]
# From type library 'wkwpac.dll'
# On Sun Nov 28 11:27:37 2004
"""Microsoft Works Word Processor 5.0 Type Library"""
makepy_version = '0.4.91'
python_version = 0x20304f0

import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing and pythoncom.Empty
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty

CLSID = IID('{F1269C08-8A8A-11D2-B46F-FA00AD000000}')
MajorVersion = 5
MinorVersion = 0
LibraryFlags = 8
LCID = 0x0

from win32com.client import CoClassBaseClass
# This CoClass is known by the name
'MicrosoftWorks.WordProcessor.AppControl.5'
class AcWp(CoClassBaseClass): # A CoClass
# Microsoft Works Word Processor AppControl
CLSID = IID('{0FF3639A-8A82-11D2-B46F-FA00AD000000}')
coclass_sources = [
]
coclass_interfaces = [
]

IAcWp_vtables_dispatch_ = 0
IAcWp_vtables_ = [
(('InitNewDocument', 'bstrTemplate'), 4096, (4096, (), [(8, 0, None,
None)], 1, 1, 4, 0, 40, (3, 0, None, None), 0)),
(('DisplayHelpTopic', 'bstrTopic'), 4097, (4097, (), [(8, 0, None,
None)], 1, 1, 4, 0, 44, (3, 0, None, None), 0)),
(('DisplayHelpTopicWithoutFocus', 'bstrTopic'), 4113, (4113, (), [(8,
0, None, None)], 1, 1, 4, 0, 48, (3, 0, None, None), 0)),
(('GetQDManager', 'ppIUnk'), 1610743811, (1610743811, (), [(16397,
10, None, None)], 1, 1, 4, 0, 52, (3, 0, None, None), 0)),
(('GetQDEdit', 'ppIUnk'), 1610743812, (1610743812, (), [(16397, 10,
None, None)], 1, 1, 4, 0, 56, (3, 0, None, None), 0)),
(('GetWindow', 'pVal'), 1610743813, (1610743813, (), [(16387, 10,
None, None)], 1, 1, 4, 0, 60, (3, 0, None, None), 0)),
(('GetDWMeasurementUnit', 'pdwUnit'), 1610743814, (1610743814, (),
[(16387, 10, None, None)], 1, 1, 4, 0, 64, (3, 0, None, None), 0)),
(('SetWABVariant', 'pvar'), 1610743815, (1610743815, (), [(16396, 10,
None, None)], 1, 1, 4, 0, 68, (3, 0, None, None), 0)),
(('MailMergeViewResults',), 1610743816, (1610743816, (), [], 1, 1, 4,
0, 72, (3, 0, None, None), 0)),
(('KillMailMergeness',), 1610743817, (1610743817, (), [], 1, 1, 4, 0,
76, (3, 0, None, None), 0)),
]

IWfxAppControl_vtables_dispatch_ = 0
IWfxAppControl_vtables_ = [
(('Initialize', 'pIWksFrame'), 1, (1, (), [(13, 1, None, None)], 1,
1, 4, 0, 12, (3, 0, None, None), 0)),
(('ProcessCommandLine', 'bstrCommandLine'), 2, (2, (), [(8, 1, None,
None)], 1, 1, 4, 0, 16, (3, 0, None, None), 0)),
(('PreProcessFrameMessage', 'uMsg', 'wParam', 'lParam', 'plResult'),
3, (3, (), [(3, 1, None, None), (19, 1, None, None), (3, 1, None,
None), (16387, 2, None, None)], 1, 1, 4, 0, 20, (3, 0, None, None),
0)),
(('PostProcessFrameMessage', 'uMsg', 'wParam', 'lParam', 'plResult'),
4, (4, (), [(3, 1, None, None), (19, 1, None, None), (3, 1, None,
None), (16387, 2, None, None)], 1, 1, 4, 0, 24, (3, 0, None, None),
0)),
(('ShowWindowFirstTime', 'hWndFrame', 'nCmdShow'), 5, (5, (), [(36,
1, None, None), (3, 1, None, None)], 1, 1, 4, 0, 28, (3, 0, None,
None), 0)),
(('CloseWindowFinalTime', 'hWndFrame'), 6, (6, (), [(36, 1, None,
None)], 1, 1, 4, 0, 32, (3, 0, None, None), 0)),
(('QueryClose',), 7, (7, (), [], 1, 1, 4, 0, 36, (3, 0, None, None),
0)),
]

RecordMap = {
'__MIDL_IWinTypes_0009': '{00000000-0000-0000-0000-000000000000}',
}

CLSIDToClassMap = {
'{0FF3639A-8A82-11D2-B46F-FA00AD000000}' : AcWp,
}
CLSIDToPackageMap = {}
win32com.client.CLSIDToClass.RegisterCLSIDsFromDic t( CLSIDToClassMap )
VTablesToPackageMap = {}
VTablesToClassMap = {
'{3A8D7EFA-737C-11D2-A379-00C04F72DA81}' : 'IWfxAppControl',
'{F1269C09-8A8A-11D2-B46F-FA00AD000000}' : 'IAcWp',
}
NamesToIIDMap = {
'IWfxAppControl' : '{3A8D7EFA-737C-11D2-A379-00C04F72DA81}',
'IAcWp' : '{F1269C09-8A8A-11D2-B46F-FA00AD000000}',
}
So, I thought I would try to using the native interfaces to get the
correct object,

The generated .py file as a few different IIDs and I am not sure how
to select which one to use. After some trials and errors, I could get
the following to work,
from pythoncom import CoCreateInstance
object = CoCreateInstance(IID('{0FF3639A-8A82-11D2-B46F-FA00AD000000}'),

None, pythoncom.CLSCTX_INPROC_SERVER, pythoncom.IID_IUnknown)

Now I have been trying to use the QueryInterface to get the correct
object and none of the IIDs mentioned in the generated file are
helping.

Appreciate if someone can help me with some pointers here as I think I
am a bit confused.

Thanks in Advance.

Puneet
Jul 18 '05 #1
0 1721

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mickel Grönroos | last post by:
Hi! I'm fiddling with Python for Windows (normally using Linux) and as a part of that I want to try to make a simple word frequency list generator to be used in conjunction with Microsoft Word....
0
by: Charles Krug | last post by:
Hello Bruces: I've created a logging class. The interface from Python's PoV works like this: X = myLogger() # Creates an instance X("some user", "some process", "A message to be logged") ...
3
by: Paul Phillips | last post by:
Here is what I am trying to do. I have an application that is written in VB 6 and in this application it is accessing a custom dll file that was created using Microsoft Fortran Professional 4.0....
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
6
by: dcrespo | last post by:
Hi to all, Can someone give me lights on how can I deal with dlls from python? My main purpose is to get access to a Unitech PT600 Bar Code system. I have the dll that works fine through...
3
by: kosmodisk | last post by:
Hi, I'm having problem accessing javascript-created elements from opened window. This occurs only when I'm including another files in opened window, javascript or css. When I comment out...
3
by: sam | last post by:
hello all, i am currently in the process of planning a piece of software to model polymerisation kinetics, and intend to use python for all the high-level stuff. the number-crunching is...
4
by: The Night Blogger | last post by:
Is there a way to push data to Microsoft Excel & Word from a Python Application Is this a cross platform feature ? I'll need to push data on MS Windows & Mac OS X ....
0
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.