Jump to content

Running a macro in Access


foamRoller
 Share

Recommended Posts

I'm trying to run a Access DB macro. Right now I'm getting a syntax error, couldn't find much help in the last couple of hours. :(

In the longterm, I'd like to have a GUI list of all the macros in that particular DB, and allow the user to choose which macro to run.... in this snippet, $db is the .accdb file path.

$accApp = ObjGet($db,"")
$macro = ObjCreate("Access.AllMacros.Application")
$dbs = $accApp.CurrentProject

for $macro in $dbs.AllMacros
    If $macro.IsLoaded = True Then
        ConsoleWrite(ObjName($macro))
    EndIf
Next $macro

$accApp.CloseCurrentDatabase
Link to comment
Share on other sites

#include "boc-library.au3"

$accApp = ObjGet($bocdb,"")
$macro = ObjCreate("Access.AllMacros.Application")
$dbs = $accApp.CurrentProject

for $macro in $dbs.AllMacros
   MsgBox(1, "macro", ObjName($macro))
Next

Here's a running version, all of the msgboxes come up as "Access Object" - is there some way to get the actual macro name? Still wondering how to run it too...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...