Well, my problem is that I created a Sub VBA that gets a link to excel Cell and 2 text values โโand a Variant as parameter.
Sub CreateButton(oCell, sLabel, sOnClickMacro, oParameters)
This subo managed to create a button above oCell, but I have to send the parameter to the macro, what is the best way to achieve this?
If you dug up some ways that didnโt work, as well as other dirty ones that donโt make me fill confortable
Using this help, I was able to solve the problem, I am suppressing here a simpler working solution for
Sub Button_Click(sText) MsgBox "Message: " & sText End Sub Sub Test_Initiallize() Dim oCell Dim oSheet Dim oShape Set oCell = Range("A1") Set oSheet = ThisWorkbook.Sheets(1) For Each oShape In oSheet.Shapes oShape.Delete Next Set oShape = oSheet.Shapes.AddShape(msoShapeRectangle, oCell.Left, oCell.Top, oCell.Width, oCell.Height) oShape.TextFrame.Characters.Text = "Click Me" oShape.OnAction = "'Button_Click ""Hello World""'" End Sub
source share