Python Forum

Full Version: how to handle COM Typelib OUT parameters?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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