Python Forum
how to handle COM Typelib OUT parameters? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to handle COM Typelib OUT parameters? (/thread-15167.html)



how to handle COM Typelib OUT parameters? - Erhy - Jan-06-2019

Hello!
I try to convert VB-Script to Python script.
I use the packages pywin32, comtypes and pythoncom

I have problems with function imported from typelib having out parameters

e.g. the code with comtypes.client.GetModule generated import file:

COMMETHOD([dispid(1610809357), helpstring('attributes at given index, returns optionally attributes range'), 'propget'], HRESULT, 'Attributes',
              ( ['in'], c_int, 'index' ),
              ( ['out', 'optional'], POINTER(VARIANT), 'range', 0 ),
              ( ['out', 'retval'], POINTER(POINTER(IPLDictionary)), 'pVal' ))
How to handle the out parameter 'range', which have not the retval attribute?

Although I have declared the values
actIndex : int = textRange[0]
attributesRange : COM.VARIANT = COM.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_ARRAY, [ 0, 0])
with
gotattributes = textInLayer.Attributes(actIndex, attributesRange)
I got
TypeError
int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Thank you for advice
Erhy


RE: how to handle COM Typelib OUT parameters? - Erhy - Jan-26-2019

after many days I quit.
It seems there is no way to code for functions with OUT parameters defined in IDL.

My last trying was to import only win32com.client, but the error message is the same:
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Tried also with python and pywin32-master from source, but I was not able to find the reason in debug mode.

Had a great hope to port .vbs scripts to python scripts