MS Access RunCode Macro cannot find my procedure

前端 未结 9 1440
一整个雨季
一整个雨季 2020-12-10 11:24

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

9条回答
  •  庸人自扰
    2020-12-10 11:44

    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.

提交回复
热议问题