[python-win32] COM Automation: Problem Accessing Property of Object

Tim Roberts timr at probo.com
Tue May 22 17:47:07 EDT 2018


Emre CETIN wrote:
>
> Finally I got it to work! Here it is:
>
> |importwin32com.client srf
> =win32com.client.gencache.EnsureDispatch('Surfer.Application')Plot=srf.Documents.Add(1)srf.Visible=TrueMapFrame1=Plot.Shapes.AddImageMap(GridFileName="C:/test.grd")ImageLayer1=MapFrame1.Overlays(1)ImageMap1
> = win32com.client.CastTo(ImageLayer1, "IImageLayer") # the property
> was under IImageLayer ImageMap1.ShowColorScale = True|
>

For future maintenance purposes, you might consider changing the names
to match the interfaces:

    Shape1 = MapFrame1.Overlays(1)
    ImageLayer1 = win32com.client.CastTo(Shape1, "IImageLayer" )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list