View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bruce B[_2_] Bruce B[_2_] is offline
external usenet poster
 
Posts: 8
Default Create Command Button from Code



Thanks John!

I decided to use the Forms command button.

I added the following code:

Sub Macro8()

ActiveSheet.Buttons.Add(100, 40, 78.75, 27.75).Select
Selection.Name = "x"
Selection.Caption = "xxxxxx"
Selection.OnAction = "subX"

End Sub

Sub subX()

Debug.Print "x"


End Sub

This works fine.

However, how do I reference the button or find out property values? I
tried several things in subX, such as:

Debug.Print "cap: " & x.Caption

but got an error.

I tried called using:
subX(Me)
sub subX(byval o as object) 'and as commandbutton
but still got error (object related).

Do you know how I can do this?

Thanks again.

- Bruce





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!