Does anybody know how to get a list of macros in an access database from VB.net?
You have to add a reference to your Access application first:
(I am using access 2000 in this example)
References->Add References->Browse->"C:\Program Files\Microsoft
Office\Office"
Select "MSACC9.OLB" (or the appropriate version of your library)
"OK"
Now the code is simple.
An example:
(A VB.net Console application)
Module Module1
Sub Main()
Dim ThisAccessProject As New Access.Application
ThisAccessProject.OpenCurrentDatabase(filepath:="C:\Test.mdb",
exclusive:=False)
'ThisAccessProject.OpenAccessProject(filepath:="C:\Test.adp",
exclusive:=False)
Dim ThisMacro As Access.AccessObject
For Each ThisMacro In
ThisAccessProject.CurrentProject.AllMacros
Console.WriteLine(ThisMacro.Name)
Next
ThisAccessProject.CloseCurrentDatabase()
End Sub
End Module
Which lists out the macros in "C:\Test.mdb", as a console app.
(Swap the comment over from the .adp to the .mdb line if your
application so requires it.)
By the way, it may speed up future responses if you state exactly
which versions of everything you are using.