View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jag Man Jag Man is offline
external usenet poster
 
Posts: 38
Default Creating Sub CommandButton1_Clk programmatically

I am trying to create a Worksheet from within a Sub procedure. I can create
a
command button ActiveX control with
ActiveWorkbook.Sheets.Add Type:=xlWorksheet
ActiveWorkbook.ActiveSheet.Name = "mixer"
ActiveWorkbook.ActiveSheet.OLEObjects.Add
ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=140, Top:=30, _
Width:=100, Height:=40
ActiveWorkbook.ActiveSheet.OLEObjects("CommandButt on1"). _
Object.Caption = "Calculate"

This automatically creates an associated Sub:

Private Sub CommandButton1_Click()

End Sub

Is there any way to then complete this "stub?" That is, I'd like to put in
its body "myFunction", programmatically,
so it becomes:


Private Sub CommandButton1_Click()
myFunct
End Sub

TIA

Ed