I\'m only posting this since I wasn\'t able to find a solution anywhere. I finally figured it out. Kind of silly really.
When using the RunCode property within an
My VSTO C# calls to app.Run("MyMacro")
stopped working suddenly and the error message started printing. ("Access cannot find the procedure MyMacro.")
The problem on my machine was that my code (which connected to a running instance of Access) was connecting to a zombie database instance that did not have that VBA macro in it. Go figure. The zombie instance did not show in the Taskbar, in the Alt-TAB display, or in a list of windows that I printed out using a console program.
The way I discovered it was to have my VSTO code print out the name of the database that it was connecting to. The Access database was one that I had been working with earlier in the day, without errors. I had closed the Access app holding it successfully hours before I tried running MyMacro.
I can't think of anything that I did that was unusual, other than upgrading VStudio to the latest version. Probably a reboot will fix things. What a weird problem.
Another solution that worked for me:
The module name can NOT have the same name as the procedure(s) in the module(s).
I had a similar issue with the error message. My VBA code had the following declaration:
private function MyFunction()
....
end function
I removed private
declaration to get the Macro Runcode
to execute the MyFunction()
For example:
Function MyFunction()
End Function