<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div><div>Thank you for your reply. I wanted to try it but for seom reason the code that has been running without a problem suddenly gave this error:</div><div><br></div><div><br></div><div><span>import win32com.client</span></div><div><span></span><br></div><div><span>srf = win32com.client.gencache.EnsureDispatch('Surfer.Application')  # after this line of code the error below is produced...<br></span></div><div><span></span><br></div><div> <span><div class="ydpbcde2ac7output_subarea ydpbcde2ac7output_text ydpbcde2ac7output_error"><pre><span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold">---------------------------------------------------------------------------</span>
<span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold">AttributeError</span>                            Traceback (most recent call last)
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold"><ipython-input-2-5e3c96b21b0e></span> in <span class="ydpbcde2ac7ansi-cyan-fg"><module></span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">()</span>
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">----> 1</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold"> </span>srf <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> win32com<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>client<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>gencache<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>EnsureDispatch<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">'Surfer.Application'</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>

<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">C:\Program Files\Anaconda3\lib\site-packages\win32com\client\gencache.py</span> in <span class="ydpbcde2ac7ansi-cyan-fg">EnsureDispatch</span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">(prog_id, bForDemand)</span>
<span class="ydpbcde2ac7ansi-green-fg">    538</span>                         tlb<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> index <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> ti<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>GetContainingTypeLib<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-fg">    539</span>                         tla <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> tlb<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>GetLibAttr<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">--> 540</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">                         </span>mod <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> EnsureModule<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span>tla<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">[</span><span class="ydpbcde2ac7ansi-cyan-intense-fg ydpbcde2ac7ansi-bold">0</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">]</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> tla<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">[</span><span class="ydpbcde2ac7ansi-cyan-intense-fg ydpbcde2ac7ansi-bold">1</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">]</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> tla<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">[</span><span class="ydpbcde2ac7ansi-cyan-intense-fg ydpbcde2ac7ansi-bold">3</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">]</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> tla<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">[</span><span class="ydpbcde2ac7ansi-cyan-intense-fg ydpbcde2ac7ansi-bold">4</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">]</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> bForDemand<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span>bForDemand<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-fg">    541</span>                         GetModuleForCLSID<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span>disp_clsid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-fg">    542</span>                         <span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold"># Get the class from the module.</span>

<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">C:\Program Files\Anaconda3\lib\site-packages\win32com\client\gencache.py</span> in <span class="ydpbcde2ac7ansi-cyan-fg">EnsureModule</span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">(typelibCLSID, lcid, major, minor, progressInstance, bValidateFile, bForDemand, bBuildHidden)</span>
<span class="ydpbcde2ac7ansi-green-fg">    395</span>         <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">try</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">:</span>
<span class="ydpbcde2ac7ansi-green-fg">    396</span>                 <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">try</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">:</span>
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">--> 397</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">                         </span>module <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> GetModuleForTypelib<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span>typelibCLSID<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> lcid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> major<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> minor<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-fg">    398</span>                 <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">except</span> ImportError<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">:</span>
<span class="ydpbcde2ac7ansi-green-fg">    399</span>                         <span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold"># If we get an ImportError</span>

<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">C:\Program Files\Anaconda3\lib\site-packages\win32com\client\gencache.py</span> in <span class="ydpbcde2ac7ansi-cyan-fg">GetModuleForTypelib</span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">(typelibCLSID, lcid, major, minor)</span>
<span class="ydpbcde2ac7ansi-green-fg">    264</span>         <span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold"># module to our cache though - check that here.</span>
<span class="ydpbcde2ac7ansi-green-fg">    265</span>         <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">if</span> <span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">"_in_gencache_"</span> <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">not</span> <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">in</span> mod<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>__dict__<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">:</span>
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">--> 266</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">                 </span>AddModuleToCache<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span>typelibCLSID<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> lcid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> major<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> minor<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span>
<span class="ydpbcde2ac7ansi-green-fg">    267</span>                 <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">assert</span> <span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">"_in_gencache_"</span> <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">in</span> mod<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>__dict__
<span class="ydpbcde2ac7ansi-green-fg">    268</span>         <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">return</span> mod

<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">C:\Program Files\Anaconda3\lib\site-packages\win32com\client\gencache.py</span> in <span class="ydpbcde2ac7ansi-cyan-fg">AddModuleToCache</span><span class="ydpbcde2ac7ansi-blue-intense-fg ydpbcde2ac7ansi-bold">(typelibclsid, lcid, major, minor, verbose, bFlushNow)</span>
<span class="ydpbcde2ac7ansi-green-fg">    556</span>         <span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold"># module - this doesn't mean anything special though!</span>
<span class="ydpbcde2ac7ansi-green-fg">    557</span>         mod<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>_in_gencache_ <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> <span class="ydpbcde2ac7ansi-cyan-intense-fg ydpbcde2ac7ansi-bold">1</span>
<span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">--> 558</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">         </span>dict <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> mod<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>CLSIDToClassMap
<span class="ydpbcde2ac7ansi-green-fg">    559</span>         info <span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">=</span> str<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span>typelibclsid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> lcid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> major<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> minor
<span class="ydpbcde2ac7ansi-green-fg">    560</span>         <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">for</span> clsid<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">,</span> cls <span class="ydpbcde2ac7ansi-green-intense-fg ydpbcde2ac7ansi-bold">in</span> dict<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">.</span>items<span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">(</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">)</span><span class="ydpbcde2ac7ansi-yellow-intense-fg ydpbcde2ac7ansi-bold">:</span>

<span class="ydpbcde2ac7ansi-red-intense-fg ydpbcde2ac7ansi-bold">AttributeError</span>: module 'win32com.gen_py.54C3F9A2-980B-1068-83F9-0000C02A351Cx0x1x4' has no attribute 'CLSIDToClassMap'

</pre></div></span>Any idea of what this is and how to solve it?<br></div><div><br></div><div class="ydpcc075b0signature"><div style="font-size:16px;"><font size="3" face="verdana, helvetica, sans-serif" color="#4c76a2"><b>E m r e</b></font><br></div></div></div>
            <div><br></div><div><br></div>
            
            <div id="yahoo_quoted_7686319446" class="yahoo_quoted">
                <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                    
                    <div>
                        On Tuesday, May 22, 2018, 8:14:34 PM GMT+3, Tim Roberts <timr@probo.com> wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                    <div><div dir="ltr">Emre CETIN via python-win32 wrote:<br clear="none">> Hi, I've been looking for a solution to this question for some time<br clear="none">> now. Hopefully you could help me out. There's a program (Golden<br clear="none">> Software Surfer) that I have successfully automated using Python COM.<br clear="none">> I normally am able to control every portion I need. The part I have<br clear="none">> trouble accessing is under its "Property Manager". Even though I am<br clear="none">> using the description provided in the software's documents & help<br clear="none">> files I get an error saying:<br clear="none">><br clear="none">> AttributeError: '<win32com.gen_py.Surfer 13 Type Library.IShape<br clear="none">> instance at 0x2327715907232>' object has no attribute 'ShowColorScale'<br clear="none">><br clear="none">> "ShowColorScale" is just an example of one property/method in the<br clear="none">> Property Manager window.<br clear="none">><br clear="none">> Here is the example code I have been working with:<br clear="none">> |importwin32com.client srf<br clear="none">> =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)ImageLayer1.ShowColorScale=True#<br clear="none">> this is where i get the error|<br clear="none"><br clear="none">The problem here, I think, is that ShowColorScale is a property of the<br clear="none">IContourMap interface, but you've been given an IShape interface.  One<br clear="none">of the issues about COM is that some objects implement many different<br clear="none">interfaces, and you have to know which interface to ask for to get the<br clear="none">methods and properties you want.<br clear="none"><br clear="none">The answer, as the old poster suggested, is to query the IShape object<br clear="none">for its IContourMap interface.  It shouldn't be very much more<br clear="none">complicated than this:<br clear="none"><br clear="none">    ImageMap1 = ImageLayer1.CastTo( "IContourMap" )<br clear="none">    ImageMap1.ShowColorScale = True<br clear="none"><br clear="none">-- <br clear="none">Tim Roberts, <a shape="rect" ymailto="mailto:timr@probo.com" href="mailto:timr@probo.com">timr@probo.com</a><br clear="none">Providenza & Boekelheide, Inc.<div class="yqt8433050524" id="yqtfd84042"><br clear="none"><br clear="none">_______________________________________________<br clear="none">python-win32 mailing list<br clear="none"><a shape="rect" ymailto="mailto:python-win32@python.org" href="mailto:python-win32@python.org">python-win32@python.org</a><br clear="none"><a shape="rect" href="https://mail.python.org/mailman/listinfo/python-win32" target="_blank">https://mail.python.org/mailman/listinfo/python-win32</a><br clear="none"></div></div></div>
                </div>
            </div></div></body></html>