Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim MyR As Range, MyB As OLEObject
- Dim MyR_T As Long, MyR_L As Long
- Set MyR = Cells(i + 1, 11) 'just an example - you get that from your own script
- MyR_T = MyR.Top 'capture positions
- MyR_L = MyR.Left '...
- 'create button
- Set MyB = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False)
- 'set main button properties
- With MyB
- .Name = "MyPrecodedButton" 'important - code must exist ... see below
- .Object.Caption = "MyCaption"
- .Top = MyR_T
- .Left = MyR_L
- .Width = 50
- .Height = 18
- .Placement = xlMoveAndSize
- .PrintObject = True 'or false as per your taste
- End With
- Dim MyR As Range, MyB As OLEObject
- Dim MyR_T As Long, MyR_L As Long
- Set MyR = Cells(i + 1, 11) 'just an example - you get that from your own script
- MyR_T = MyR.Top 'capture positions
- MyR_L = MyR.Left '...
- 'create button
- Set MyB = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False)
- 'set main button properties
- With MyB
- .OnAction = "interpHere"
- .Name = "MyPrecodedButton" 'important - code must exist ... see below
- .Object.Caption = "MyCaption"
- .Top = MyR_T
- .Left = MyR_L
- .Width = 50
- .Height = 18
- .Placement = xlMoveAndSize
- .PrintObject = True 'or false as per your taste
- End With
- Sub interpHere()
- MsgBox "hi"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement