Access VBA: Shell command broken in one particular database

半腔热情 提交于 2020-03-05 05:19:24

问题


I have two Access databases that I'm opening on the same computer. In one, running this in the immediate window works as expected (opens Notepad):

Shell "notepad.exe"

In the other, I get this error instead:

Run-time error '5': Invalid procedure call or argument

I have not been able to come up with any shell command that will run successfully in that second database. No matter what, I get that error.

What is going on here? Could there be a security setting coming into play? Or perhaps one is an older version?

Edit - More Info

  • When I go to the definition of Shell in the malfunctioning database, it goes to VBA.Interaction.Shell.

  • I get the correct IntelliSense tooltip for Shell.

  • I tried VBA.Shell "notepad.exe" and VBA.Interaction.Shell "notepad.exe" without success (same error).

  • Here are the references that are checked in both databases:

  • Decompiling did not help.


回答1:


The culprit was our anti-virus software! UGH!

Why did it work in one database and not the other then? I'm told that years ago, anti-virus exceptions were made for my computer for the one database but not the other.

I recommend that any others who encounter this problem check their anti-virus logs/policies. Also, running the database from another computer with different policies in place might shed some light on the issue faster. In this case, when I used remote desktop to log into a server, I was able to call shell successfully.



来源:https://stackoverflow.com/questions/56676948/access-vba-shell-command-broken-in-one-particular-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!