0
votes

Is that not possible?

My main goal is to create a button/shape with VBA on the sheet that will run a xlam sub. But I can't connect a button to the xlam sub.

I try to right click on the button and click on... I don't know. Run macro? I have Swedish Excel so I don't know what the option is called in English.
But the options I get is only the local macro that is in the workbook not the xlam.

I try to record a macro of what happens when I connect a local macro to it, and I get:

Selection.OnAction = "Makro3"

So the obvious would be to replace that with:

Selection.OnAction = "'STAGE.xlam'!urklipp"

But the code does not run and I get no errors.
I can however use "pure" VBA inside a local workbook macro:

Application.Run "'STAGE.xlam'!urklipp"

But that means the local workbook needs to have a macro to run the xlam which is not possible since the local workbook is an export of data from SAP.

Anyone know a way to run a xlam sub from a button/shape?

2
Maybe here you'll find something usefull. - barneyos
@barneyos Thank you! There was a answer that worked. (or at least gave me the clue what the problem was). - Andreas

2 Answers

1
votes

The problem is the module was not included in the OnAction.

 Selection.OnAction = "'STAGE.xlam'!Modul1.urklipp"
-1
votes

Sub Button1_Click() Application.Run ("myfile.xlam!XYZ") End Sub

(XYZ is what you want to run). Let me know if this works