I had a really annoying problem, which I've kind of solved, but was wondering if it could be done more elegantly or simply. since it is about as non-intuitive as you can get at the moment. What I was trying to do was to emulate the pressing of one of the buttons on the ribbon in Excel 2010 from a macro. Eventually I ended up with this
Const cIncreaseDecimal = 398
Application.CommandBars.FindControl(ID:=cIncreaseD ecimal).Execute
which is from "old" Excel (pre 2003), but works in 2010. However, while researching this I thought it would be much easier and wouldn't require me finding the "ID" of the command, if I could call a keyboard shortcut from within a macro. Then I could assign whatever shortcut I wanted to whatever button I wanted, then just call that KB shortcut from in the macro. I know the opposite is possible (ie calling a macro from a KB shortcut), but is it possible to do this?
I initially tried recording a macro of the button press and using that ,which usually works fine, but the code for the button seems to read the current number of decimals and then it just runs this when I increased the number of decimals, so some of the code is actually missing!!
Selection.NumberFormat = "0.0000" (my original number had 3 decimal places).
Anyway, if anyone knows a way to run a keyboard shortcut in a macro, I'd really like to know.
Thanks!



