Toad World® Forums

Run an Access macro from TDP

Is there a way to run an existing Access macro from TDP? When I connect to the db I do not see the existing queries, macros, or modules.

See if you using the MS Access AutoExec functionality may meet your needs…

In your Execution Target tab put the following in:

Target: This is the path to your MSACCESS.EXE program.
C:\Program Files\Microsoft Office\Office15\msaccess.exe

Command-Line Parameters:“C:\My Documents\MyDatabase\Customers.accdb” /x “Name_OF_Your_MACRO”
This is the path to your access database. You need to put the quotes in there.

Startup Directory:
C:\My Documents\MyDatabase

Just remember, when the macro is run, should have an entry in there to exit access when the macro has completed. Otherwise, Access will just stay open.

Thanks everyone!

Hi all,

You can also execute a vbscript using Toad to launch macros !

I use to do that with Excel to format exported data in .xlsx files. No need to share files with macros (more secure)…

for example : a file named “excel_launcher.vbs”

Option Explicit
On Error Resume Next

Sub ExempleMacroExcel()

Dim ApplicationExcel
Dim ClasseurExcel

Set ApplicationExcel = CreateObject(“Excel.Application”)
Set ClasseurExcel = ApplicationExcel.Workbooks.Open(“C:\Test\MonFichierExcel.xlsm”) ‘or .xlam for macro container without worksheets’

ApplicationExcel.Visible = false
ApplicationExcel.Run “MacroTest1”
ApplicationExcel.Run “MacroTest2”

Set ClasseurExcel = Nothing
Set ApplicationExcel = Nothing

End Sub

in a “run program” activity

Program : C:\Windows\System32\wscript.exe

Arguments : “C:\MyFolder\excel_launcher.vbs”

Run Directory : C:\MyFolder

I hope this help…


Beside isolated solutions as others already mentioned here, there is also an officially supported way how to do this simply by using the Export wizard where once you choose Excel as output and specify an existing “Macro enabled file” (.xlsm file extension) then a special Export Wizard page with “Before and After export macros” opens so you can specify which existing macros (public parameterless vba procedures) to execute.