I am trying to get Excel return an error message if a certain SendKeys command does not return the result I expect. In the case below, I expect an error as ALT + X will not give you any valid command (X does not appear in Excel when ALT is pressed). Ultimately, this is to test a presence of an Add-In the Excel Ribbon (which if it existed would have allowed the X key to proceed).
But no luck! Any help would be appreciated!
VBA Code:
Sub SendKeycheck()
On Error GoTo eh
Application.SendKeys ("%x")
Done:
MsgBox "All OK"
Exit Sub
eh:
MsgBox "The following error occurred: " & Err.Description
End Sub
But no luck! Any help would be appreciated!