简体   繁体   中英

Clicking Addin button in Excel Ribbon without Macro

I'm trying to find a way to automatically click a button (downloads external data), which is part of an Addin, on my Excel Ribbon using VBA or Python.

The obvious thing to do is off course trying to find the button in the Object Explorer in VBA, but it does not seem to be there. Clicking the button will trigger a process, stored in some.dll file.

I've tried to access it using a macro with SendKeys , containing the Alt shortcuts to the button in the ribbon, but running this macro from python (using win32com ) does not work. Opening a workbook using pywinauto , also didn't work properly. Alternatively, I've tried to run the macro on start-up, which is not stable either. So basically, the SendKeys approach is not an option.

Ideally, I would like to have a scheduled Python process, that fills the excel file, and afterwards clicks the button.

Any possible solution is welcome!

There is no trivial way to execute a ribbon button which comes from a third-party COM add-in. You may consider using Accessibility API (Windows API) as a possible workaround.

But better to ask add-in developers for any public methods that could run the same action assigned to the ribbon button. So, it can be called from your VBA macro, see Walkthrough: Call code in a VSTO Add-in from VBA for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM