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,
[color=blue][color=green][color=darkred]
>>> from win32com.client import Dispatch
>>> object = Dispatch("Micro softWorks.WordP rocessor.AppCon trol")[/color][/color][/color]
and I get the following error,
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\Li b\site-packages\win32c om\client\__ini t__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoo dDispatchAndUse rName(dispatch, userName,clsctx )
File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py",
line 91, in _GetGoodDispatc hAndUserName
return (_GetGoodDispat ch(IDispatch, clsctx), userName)
File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py",
line 79, in _GetGoodDispatc h
IDispatch = pythoncom.CoCre ateInstance(IDi spatch, None, clsctx,
pythoncom.IID_I Dispatch)
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
"""Microsof t 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.Missi ng and pythoncom.Empty
defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty
CLSID = IID('{F1269C08-8A8A-11D2-B46F-FA00AD000000}')
MajorVersion = 5
MinorVersion = 0
LibraryFlags = 8
LCID = 0x0
from win32com.client import CoClassBaseClas s
# This CoClass is known by the name
'MicrosoftWorks .WordProcessor. AppControl.5'
class AcWp(CoClassBas eClass): # A CoClass
# Microsoft Works Word Processor AppControl
CLSID = IID('{0FF3639A-8A82-11D2-B46F-FA00AD000000}')
coclass_sources = [
]
coclass_interfa ces = [
]
IAcWp_vtables_d ispatch_ = 0
IAcWp_vtables_ = [
(('InitNewDocum ent', 'bstrTemplate') , 4096, (4096, (), [(8, 0, None,
None)], 1, 1, 4, 0, 40, (3, 0, None, None), 0)),
(('DisplayHelpT opic', 'bstrTopic'), 4097, (4097, (), [(8, 0, None,
None)], 1, 1, 4, 0, 44, (3, 0, None, None), 0)),
(('DisplayHelpT opicWithoutFocu s', '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)),
(('GetDWMeasure mentUnit', 'pdwUnit'), 1610743814, (1610743814, (),
[(16387, 10, None, None)], 1, 1, 4, 0, 64, (3, 0, None, None), 0)),
(('SetWABVarian t', 'pvar'), 1610743815, (1610743815, (), [(16396, 10,
None, None)], 1, 1, 4, 0, 68, (3, 0, None, None), 0)),
(('MailMergeVie wResults',), 1610743816, (1610743816, (), [], 1, 1, 4,
0, 72, (3, 0, None, None), 0)),
(('KillMailMerg eness',), 1610743817, (1610743817, (), [], 1, 1, 4, 0,
76, (3, 0, None, None), 0)),
]
IWfxAppControl_ vtables_dispatc h_ = 0
IWfxAppControl_ vtables_ = [
(('Initialize', 'pIWksFrame'), 1, (1, (), [(13, 1, None, None)], 1,
1, 4, 0, 12, (3, 0, None, None), 0)),
(('ProcessComma ndLine', 'bstrCommandLin e'), 2, (2, (), [(8, 1, None,
None)], 1, 1, 4, 0, 16, (3, 0, None, None), 0)),
(('PreProcessFr ameMessage', '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)),
(('PostProcessF rameMessage', '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)),
(('ShowWindowFi rstTime', 'hWndFrame', 'nCmdShow'), 5, (5, (), [(36,
1, None, None), (3, 1, None, None)], 1, 1, 4, 0, 28, (3, 0, None,
None), 0)),
(('CloseWindowF inalTime', '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_IWinTyp es_0009': '{00000000-0000-0000-0000-000000000000}',
}
CLSIDToClassMap = {
'{0FF3639A-8A82-11D2-B46F-FA00AD000000}' : AcWp,
}
CLSIDToPackageM ap = {}
win32com.client .CLSIDToClass.R egisterCLSIDsFr omDict( CLSIDToClassMap )
VTablesToPackag eMap = {}
VTablesToClassM ap = {
'{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,
[color=blue][color=green][color=darkred]
>>> from pythoncom import CoCreateInstanc e
>>> object = CoCreateInstanc e(IID('{0FF3639 A-8A82-11D2-B46F-FA00AD000000}') ,[/color][/color][/color]
None, pythoncom.CLSCT X_INPROC_SERVER , pythoncom.IID_I Unknown)
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
After generating the .py module from the type library using makepy
utility, I runt he following commands,
[color=blue][color=green][color=darkred]
>>> from win32com.client import Dispatch
>>> object = Dispatch("Micro softWorks.WordP rocessor.AppCon trol")[/color][/color][/color]
and I get the following error,
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\Li b\site-packages\win32c om\client\__ini t__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoo dDispatchAndUse rName(dispatch, userName,clsctx )
File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py",
line 91, in _GetGoodDispatc hAndUserName
return (_GetGoodDispat ch(IDispatch, clsctx), userName)
File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py",
line 79, in _GetGoodDispatc h
IDispatch = pythoncom.CoCre ateInstance(IDi spatch, None, clsctx,
pythoncom.IID_I Dispatch)
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
"""Microsof t 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.Missi ng and pythoncom.Empty
defaultNamedOpt Arg=pythoncom.E mpty
defaultNamedNot OptArg=pythonco m.Empty
defaultUnnamedA rg=pythoncom.Em pty
CLSID = IID('{F1269C08-8A8A-11D2-B46F-FA00AD000000}')
MajorVersion = 5
MinorVersion = 0
LibraryFlags = 8
LCID = 0x0
from win32com.client import CoClassBaseClas s
# This CoClass is known by the name
'MicrosoftWorks .WordProcessor. AppControl.5'
class AcWp(CoClassBas eClass): # A CoClass
# Microsoft Works Word Processor AppControl
CLSID = IID('{0FF3639A-8A82-11D2-B46F-FA00AD000000}')
coclass_sources = [
]
coclass_interfa ces = [
]
IAcWp_vtables_d ispatch_ = 0
IAcWp_vtables_ = [
(('InitNewDocum ent', 'bstrTemplate') , 4096, (4096, (), [(8, 0, None,
None)], 1, 1, 4, 0, 40, (3, 0, None, None), 0)),
(('DisplayHelpT opic', 'bstrTopic'), 4097, (4097, (), [(8, 0, None,
None)], 1, 1, 4, 0, 44, (3, 0, None, None), 0)),
(('DisplayHelpT opicWithoutFocu s', '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)),
(('GetDWMeasure mentUnit', 'pdwUnit'), 1610743814, (1610743814, (),
[(16387, 10, None, None)], 1, 1, 4, 0, 64, (3, 0, None, None), 0)),
(('SetWABVarian t', 'pvar'), 1610743815, (1610743815, (), [(16396, 10,
None, None)], 1, 1, 4, 0, 68, (3, 0, None, None), 0)),
(('MailMergeVie wResults',), 1610743816, (1610743816, (), [], 1, 1, 4,
0, 72, (3, 0, None, None), 0)),
(('KillMailMerg eness',), 1610743817, (1610743817, (), [], 1, 1, 4, 0,
76, (3, 0, None, None), 0)),
]
IWfxAppControl_ vtables_dispatc h_ = 0
IWfxAppControl_ vtables_ = [
(('Initialize', 'pIWksFrame'), 1, (1, (), [(13, 1, None, None)], 1,
1, 4, 0, 12, (3, 0, None, None), 0)),
(('ProcessComma ndLine', 'bstrCommandLin e'), 2, (2, (), [(8, 1, None,
None)], 1, 1, 4, 0, 16, (3, 0, None, None), 0)),
(('PreProcessFr ameMessage', '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)),
(('PostProcessF rameMessage', '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)),
(('ShowWindowFi rstTime', 'hWndFrame', 'nCmdShow'), 5, (5, (), [(36,
1, None, None), (3, 1, None, None)], 1, 1, 4, 0, 28, (3, 0, None,
None), 0)),
(('CloseWindowF inalTime', '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_IWinTyp es_0009': '{00000000-0000-0000-0000-000000000000}',
}
CLSIDToClassMap = {
'{0FF3639A-8A82-11D2-B46F-FA00AD000000}' : AcWp,
}
CLSIDToPackageM ap = {}
win32com.client .CLSIDToClass.R egisterCLSIDsFr omDict( CLSIDToClassMap )
VTablesToPackag eMap = {}
VTablesToClassM ap = {
'{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,
[color=blue][color=green][color=darkred]
>>> from pythoncom import CoCreateInstanc e
>>> object = CoCreateInstanc e(IID('{0FF3639 A-8A82-11D2-B46F-FA00AD000000}') ,[/color][/color][/color]
None, pythoncom.CLSCT X_INPROC_SERVER , pythoncom.IID_I Unknown)
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