Pythonwin and Office 2000

Paul Prescod paul at prescod.net
Sun Jun 27 21:37:42 EDT 1999


Mark Hammond wrote:
> 
> Paul Prescod wrote in message <377648A7.9B9BE59F at prescod.net>...
> >I believe that Pythonwin is not compatible with Office 2000. Here are some
> >symptoms:
> 
> I havent tried this, although I believe it!

Well, I got it to work eventually. I used the command line makepy instead
of the one in the GUI. It didn't test the result before it registered it
in the .dat file. Then I edited the file by hand to remove the upper-case
"L" characters.

> This is expected (unfortunately).  Word will have a new typelibrary, and
> hence a new IID for the library.  The "fix" will be to work out what the
> library ID of the new one is (by using "makepy -i") and changing TestWord.py
> to gracefully allow either version.

 >>> # Use these commands in Python code to auto generate .py support
 >>> from win32com.client import gencache
 >>> gencache.EnsureModule('{91493440-5A91-11CF-8700-00AA0060263B}', 0, 2,
14)

Is there an equivalent to EnsureModule that works from the textual library
name? I know that the textual library name still changes from version to
version but I don't think it is Pythonish (easy, clean and readable) to
put UUIDs in code at all.

In fact, the most Pythonish way would be to do what Python does with
Pyc's. When Pythonwin does a win32com.client.Dispatch, it could generate
the gencache module if possible. If not possible then no problem, it just
works in the dynamic mode.

Also, is there any chance of having win32com.client.Dispatch renamed
CreateObject() for JavaScript and VBScript compatibility?

> >    def AddOLEObject(self, Left=0.0, Top=0.0, Width=-1.0, Height=-1.0,
> >ClassName
> >=L'', FileName=L'', DisplayAsIcon=0, IconFileName=L'', IconIndex=0,
> >IconLabel=L'
> >', Link=0):

Once I deleted that strange "L" thing, the generated module worked.

In case it helps, here is the code:

def AddOLEObject(self, Left=0.0, Top=0.0, Width=-1.0, Height=-1.0,
ClassName=L'', FileName=L'', DisplayAsIcon=0, IconFileName=L'',
IconIndex=0, IconLabel=L'', Link=0):
		return self._ApplyTypes_(0x7d8, 1, (9, 32), ((4, 49), (4, 49), (4, 49),
(4, 49), (8, 49), (8, 49), (3, 49), (8, 49), (22, 49), (8, 49), (3, 49)),
'AddOLEObject', '{91493479-5A91-11CF-8700-00AA0060263B}', Left, Top,
Width, Height, ClassName, FileName, DisplayAsIcon, IconFileName,
IconIndex, IconLabel, Link)

...
	# Result is of type TextRange
	def InsertAfter(self, NewText=L''):
		return self._ApplyTypes_(0x7e1, 1, (9, 32), ((8, 49),), 'InsertAfter',
'{9149348F-5A91-11CF-8700-00AA0060263B}', NewText)
...


	def Help(self, HelpFile=L'vbappt9.chm', ContextID=0):
		return self._ApplyTypes_(0x7e4, 1, (24, 32), ((8, 49), (22, 49)),
'Help', None, HelpFile, ContextID)


-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself
 http://itrc.uwaterloo.ca/~papresco

Those who profess to favor freedom and yet depreciate agitation, are men 
who want crops without plowing up the ground. They want rain without 
thunder and lightning. They want the ocean without the roar of its many 
waters. - Fredrick Douglass
 http://www.informamerica.com/Articles/Quotes.htm




More information about the Python-list mailing list