VBA - Having trouble using .OnAction Programatically

swayp11

Board Regular
Joined
Apr 27, 2009
Messages
107
Office Version
  1. 365
Platform
  1. Windows
I am inserting shapes into a sheet and I want an OnAction on each shape with a parameter (which is a variable) to call another sub.

The code runs fine and inserts the OnAction:

Code:
With tempShape
  .OnAction = "'PERSONAL.XLSB!MyMacro " & myVariable & "'"
End With

The code for the sub in my personal workbook:
Code:
Public Sub MyMacro(VariableName As String)
  'code here
End Sub


When I try and click one of the shapes though, I get:

Cannot run the macro "PERSONAL.XLSB!MyMacro VariableString". The macro may not be available in this workbook or all macros may be disabled.


Anybody know whats going on here?

Thanks!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Thanks for your reply. I tried multiple ways to pass it, but it seems as if it doesn't like the Personal Workbook. I think it needs to be in another workbook and be called locally.
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top