Click OK or X (close) button on Excel COM Add-in pop up message with VBA or Windows API VBA

huangapple go评论70阅读模式
英文:

Click OK or X (close) button on Excel COM Add-in pop up message with VBA or Windows API VBA

问题

我对Excel VBA有一些了解,但这似乎是一个不容易解决的问题。具体而言,我有一个企业级的COM插件,用于从数据库中提取数据。我们有一个简单的宏,利用这个插件的对象、方法和属性来打开数据库连接,但当执行时,会显示一个内置的弹出窗口,仅用于确认操作。这不是一个MsgBox,它甚至没有标题栏,似乎是与COM插件架构相关的。它是模态的,所以继续执行的唯一方法是确认或关闭这个弹出窗口。不幸的是,我无法提供任何屏幕截图。我考虑在运行宏之前运行一个循环来收集打开的窗口,然后再次运行循环以检查是否出现了新窗口,问题是当这个弹出窗口出现时,代码执行被停止...

英文:

I have some familiarity with Excel VBA but this seems like a non-trivial issue. Namely, I have a corporate COM Add-In that is used to pull data from database. We've got a simple macro that utilizes this Add-Ins objects, methods and properties that opens the connection to database but when executed an in-built pop up window is displayed just to confirm the action. It's not a MsgBox, it doesn't even have the title bar, it seems native to the COM Add-In architecture. It's modal so the only way to continue execution is to acknowledge or close this pop-up. Unfortunately I can't provide any screenshots. I was thinking about running a loop to gather open windows prior to unning the macro and then run the loop again to check if any new windows appeared, problem is when this pop-up appears, code execution is halted...

答案1

得分: 1

你的VBA将无法拦截弹出窗口并以编程方式执行操作,因为代码在Office应用程序的主UI线程上执行。

你可以开发一个外部可执行应用程序,它可以监视Excel中的活动窗口,并在需要时以编程方式单击所需的控件。在出现这种弹出窗口之前,你的VBA代码可以运行该应用程序。

此外,你可以询问插件开发者是否提供了任何公开可用的方法。有关更多信息,请参阅Walkthrough: Call code in a VSTO Add-in from VBA

英文:

Your VBA will not be able to intercept the popup and do actions programmatically because the code is executed on the main UI thread in Office applications.

You can develop an external executable application which could monitor the active window in Excel and click the required control programmatically when required. That application could be run by your VBA code before getting such popups.

Also you may ask for any publicly available methods provided by add-in developers. See Walkthrough: Call code in a VSTO Add-in from VBA for more information.

huangapple
  • 本文由 发表于 2023年7月11日 00:30:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定