title: Running VBA macro within Access 2010 from external VBScript
body: <p>Not sure this is possible, but it seems like it should be doable.... it is 2013 after all! And some forum posts I found suggest it is, but I have not been successful in getting it to work...</p>
  
  <p>I have an Access 2010 db with a macro that downloads files from 3 different web sites and then proceeds to import the data and process it. It runs for 1hr and 17 mins.</p>
  
  <p>I want to schedule this macro to run at 4am so it is all done and dusted by coffee time and work start 8am... So I created a VBScript to run this, which will then be placed into the Task Scheduler for the desired time.</p>
  
  <p>It is a single user DB, my use only on my PC.</p>
  
  <p>I have done some research but I cannot seem to get this working. Here's what I have so far:</p>
  
  <p>Macro inside "Main" module in Access 2010 inside of "Pricing Model.accdb":</p>
  
  <pre><code>Public Sub Download_And_Import()
      ProcStep = ""
      ExecStep = 1
      DoCmd.SetWarnings False
      'Empty the Execution Progress table
      DoCmd.RunSQL "DELETE * FROM EXECUTION_PROGRESS"
      Call Update_EXECUTION_PROGRESS(Format(Now(), "YYYY/MM/DD HH:MM:SS"), ExecStep, "Starting Download_Files Main Procedure...")
      Call Download_Files.Download_Files
      Call Update_EXECUTION_PROGRESS(Format(Now(), "YYYY/MM/DD HH:MM:SS"), ExecStep, "Finished Download_Files Main Procedure...")
      Call Update_EXECUTION_PROGRESS(Format(Now(), "YYYY/MM/DD HH:MM:SS"), ExecStep, "Starting Import_Files Main Procedure...")
      Call Import_Files.Import_Files
      Call Update_EXECUTION_PROGRESS(Format(Now(), "YYYY/MM/DD HH:MM:SS"), ExecStep, "Finished Import_Files Main Procedure, closing application now...")
      DoCmd.SetWarnings True
  End Sub
  </code></pre>
  
  <p>I then created the following VBScript to run Access VBA Macro externally:</p>
  
  <pre><code>dim accessApp
  set accessApp = createObject("Access.Application")
  accessApp.OpenCurrentDataBase("G:\Pricing DB\Pricing Model.accdb")
  accessApp.Run "Download_And_Import"
  accessApp.Quit
  set accessApp = nothing
  </code></pre>
  
  <p>I get the message "Illegal function call, Line 4" which is the step:</p>
  
  <pre><code>accessApp.Run "Download_And_Import"
  </code></pre>
  
  <p>Any ideas / help is highly appreciated! Thanks in advance!</p>
  
  <p>M</p>