P
Puneet Jain
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,
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,userName,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.RegisterCLSIDsFromDict( 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,
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
After generating the .py module from the type library using makepy
utility, I runt he following commands,
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,userName,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.RegisterCLSIDsFromDict( 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,
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