2

I want to add .onAction with three variables to a button on an Excel sheet.

I followed Excel, VBA: How to pass multiple variables to .OnAction to pass multiple variables.

When I click the button, it is throwing an error

"Cannot Run the Macro "Deck v.1'!'Stop_SAP "10.x.x.x", sidadm, " ". The macro may not be available in this workbook or all macros has been disabled.

If I don't pass any variables it is working.

.OnAction = "Stop_SAP"

With btn1
    .TextFrame.Characters.Font.Size = 8
    .TextFrame.Characters.Caption = "Stop SAP"
    .OnAction = "'Stop_SAP """ & hstname & """ ,""" & usrname & """,""" & pass & """'"
    .Line.visible = False
End With
1
  • Is the procedure you are calling in a regular module? - Or did you put it into a WB/WS-module. If so put it into a regular module Commented Jun 3, 2023 at 18:07

1 Answer 1

1

The problem was with existing shapes. Just delete all shapes on the exit using

Dim Shp As Shape

For Each Shp In ActiveSheet.Shapes
 Shp.Delete
Next Shp
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.