Programming Resources

Adding parameters to the OnAction property of Excel buttons

Sometimes you need to pass parameters via a button in Excel but the standard OnAction property syntax does not allow this. If you try .OnAction="myProc(99,'Some text')" you will receive an error. But there is a way to get around this.

 

 

You can add a parameter to the OnAction property of the button. If you had a procedure like this:

Sub myProc(id As Integer, myText As String) 
MsgBox (id & " " & myText)
End Sub

You can set the OnAction property of a button as follows:

sheet1.Shapes(1).OnAction = "'myProc 99,""Some text""'"

Careful with the quotes and double quotes, you need single quotes around the entire procedure call and parameters, you need repeated double quotes around strings. Separate parameters with commas.

 

If you are looking for property in Piemonte Italy then we recommend alba property and piedmont property. Italian real estate.

Home > Programming Resources > Excel > Adding parameters to the OnAction property of Excel buttons

Contact

Telephone: 020 7193 2301
Email: webcontact@fearntech.co.uk

Full Contact Details >

 

© 2001-2008 Fearntech Limited. All rights reserved.
website design kent | seo kent | website maintenance
Valid XHTML | Valid CSS