title: Run MS access Function from python
body: <p>Trying to run MS access function from python. Note that I have Access macro object with <code>RunCode</code> action that calls the function in the module 2. This macro is nameed as  <code>del_all_records()</code> , function has the same name too <code>del_all_records()</code></p>
  <p>This is my python code:</p>
  <pre><code># search for directory
  directory = r'C:/Users/' + username + /Documents/Customer/02.weekly Report/'
  
  ac = win32com.client.Dispatch(&quot;Access.Application&quot;)
  ac.Visible=True
  ac.OpenCurrentDatabase(directory +'/amazon.accdb')
  ac.DoCmd.RunMacro('del_all_records()')
  ac = None
  </code></pre>
  <p>This trace back error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;directory = r'C:/Users/' + username + /Documents/Customer/02.weekly Report/db_load.py&quot;, line 15, in &lt;module&gt;
      ac.DoCmd.RunMacro('del_all_records()')
    File &quot;&lt;COMObject &lt;unknown&gt;&gt;&quot;, line 2, in RunMacro
  pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, 'You canceled the previous operation.', 'vbaac10.chm', 5738, -2146826287), None)
  </code></pre>