Share this page

# Example: Adding Button Functionality

This example opens a calculator when a user clicks a button defined with action name `Calculator`. For details about adding user-defined buttons, see Adding a Button to a Toolbar.

Add the code to the `ActionCanExecute` event procedure, so that it is triggered when a user initiates an action.

For information about the Wscript.Shell object, refer to the Microsoft documentation. To access help for the VBScript language, choose Help > VBScript Home Page in the Script Editor.

    Function ActionCanExecute(ActionName)
            ' Initialize the function's return value to
    	 ' avoid unpredictable behavior.
            ActionCanExecute = DefaultRes
            On Error Resume Next
            If ActionName = "UserDefinedActions.Calculator" Then
                Set shell = CreateObject("Wscript.Shell")
                shell.Run "Calc"
                Set shell = Nothing
            End If
            ActionCanExecute = DefaultRes
            PrintError "ActionCanExecute"
            On Error GoTo 0
    End Function

https://admhelp.microfocus.com ALM 8942
Tips to improve your search results... ALM Help Center ALM Help Center ALM Help 15.5-15.5.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: