Executing Dynamics AX add-in commands from macro VBA code

Question Status

Michal Besta asked a question on 31 Aug 2012 1:04 AM

Somebody knows how to call Dynamics AX -> Refresh All action (Excel add-in) in VBA code (macro)?

Building some Excel application based on Dynamics AX data (export, import) but forcing user to find proper function in ribbon is inconvenient (sometimes ribbon even looses focus and user needs to select a cell inside source table before he can execute commands).

AaronEmde responded on 5 Apr 2013 5:07 PM

I would like this functionality as well!

KlonEntek responded on 23 Jun 2014 4:07 PM

I have used the sendkeys function to refresh all from VBA.

Application.SendKeys "%Y1R~"

This is what the characters mean: % = Alt, Y1 = The Dynamics AX Tab, R = Refresh, ~ = Enter

you should check to see if your AX is linked to Y1, it might be different from mine. to check press the Alt key while in  Excel and you will see the sendkey values for the ribbon.

you may want to read up on sendkeys before you start using it. if used incorrectly you can break things.

also you cannot, or at least I have not found how to run this in the middle of a macro reliably. run by its self or at the end of a macro seems to work fine.

I am trying to figure out how to run it in the middle so I can automate the process for my users.