Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Member not found." error using win32com
    primarykey
    data
    text
    <p>I'm having issues accessing a COM object using the Python win32com module, which I don't have when using VBA. See usage/error below. The other parts of the object are functioning OK, but I can't get any of the parameters out of the ResultSet object.</p> <pre><code>&gt;&gt;&gt; import win32com.client &gt;&gt;&gt; Aquator = win32com.client.gencache.EnsureDispatch("Aquator.Application") &gt;&gt;&gt; db = Aquator.LoadDatabase(r"D:\Shared", "AquatorExcel.mdb") &gt;&gt;&gt; project = Aquator.LoadProject(db, "A simple model", False, False) &gt;&gt;&gt; &gt;&gt;&gt; project.ModelRunStart() &lt;win32com.gen_py.Aquator Water Resource Simulation._ModelRun instance at 0x15264 824&gt; &gt;&gt;&gt; Aquator.ActiveProject.ModelRuns.Count 1 &gt;&gt;&gt; Aquator.ActiveProject.ModelRuns.Item(1).ResultSet &lt;win32com.gen_py.Aquator Water Resource Simulation._IResultSet instance at 0x149 19000&gt; &gt;&gt;&gt; Aquator.ActiveProject.ModelRuns.Item(1).ResultSet.Cost Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "C:\Program Files\Pythonxy\Pythonxy 2.7\Python27\lib\site-packages\win32c om\client\__init__.py", line 463, in __getattr__ return self._ApplyTypes_(*args) File "C:\Program Files\Pythonxy\Pythonxy 2.7\Python27\lib\site-packages\win32c om\client\__init__.py", line 456, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), pywintypes.com_error: (-2147352573, 'Member not found.', None, None) </code></pre> <p>The equivalent code in the VBA editor within the application functions correctly, returning a float:</p> <pre><code>Public Sub Test() MsgBox Aquator.ActiveProject.ModelRuns.Item(1).ResultSet.Cost End Sub </code></pre> <p>As far as I can tell, the EnsureDispatch command has done it's job correctly, and recognises the property (along with others, also inaccessible):</p> <pre><code>&gt;&gt;&gt; Aquator.ActiveProject.ModelRuns.Item(1).ResultSet._prop_map_get_.keys() ['WaterBalanceMl', 'RunDate', 'Parameters', 'DoublePrecision', 'WarningCount', ' FinishDate', 'AmountLost', 'SinglePrecision', 'Status', 'StartDate', 'Descriptio n', 'AmountLeaked', 'FailureCount', 'AmountAdded', 'ErrorCount', 'AmountStored', 'Name', 'WaterBalancePercent', 'InfoValueList', 'Results', 'States', 'Cost', 'A mountRemoved', 'Sequences', 'Duration', 'InfoNameList', 'RunTime'] &gt;&gt;&gt; Aquator.ActiveProject.ModelRuns.Item(1).ResultSet.meh Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "C:\Program Files\Pythonxy\Pythonxy 2.7\Python27\lib\site-packages\win32c om\client\__init__.py", line 462, in __getattr__ raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr )) AttributeError: '&lt;win32com.gen_py.Aquator Water Resource Simulation._IResultSet instance at 0x15175888&gt;' object has no attribute 'meh' </code></pre> <p>I have tried using .GetCost() (a la <a href="https://stackoverflow.com/questions/7089496/setting-a-property-using-win32com">Setting a property using win32com</a>), to no avail ("object has no attribute...").</p> <p>What am I doing wrong here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload