Add Button Control for Run Options in Excel
This topic explains how to insert controls, such as buttons and check boxes, directly in Microsoft Excel.
First, enable the Developer tab in Excel. By default, the Developer tab is not displayed; but, you can add it to the ribbon.
To enable the Developer tab in Excel and add button control in your worksheet
- In Microsoft Excel, select File > Options. The Excel Options window appears.
- Select Customize Ribbon, enable the Developer option, and select OK.
- To insert button in your worksheet and code to be executed on click of the button, perform the following steps:
- On the Developer tab, select Insert and select the Button (Form Control) or Command Button (ActiveX Control).
- Click and drag on the sheet to create a button. The Assign Micro window appears.
- Enter the micro name and select New.
- In Visual Basic Editor, copy the following code.
Dim CAddIn As COMAddIn
Dim ProRAddInObject As Object
Set CAddIn = Application.COMAddIns("ProcessRunnerExcelAdd-in") 'Get our Excel Add-in Object
Set ProRAddInObject = CAddIn.Object 'Get our Excel Add-in Internal Class object
ProRAddInObject.RunProcess 1,1 'Call RunProcess method and pass dropdown index 2
is for Test Run3
is for Debug Run4
is for Error Processing Run5
is for Validate Data Governance- Close the Visual Basic Editor.
- Select the button to test the control. The Process file is run with the run action specified.
where
1
indicates theRun
action. Use the following numbers for the other run options:1
indicates the index of the Process in the Excel.
Related Topics: