View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AlanGriffithKapitiNZ AlanGriffithKapitiNZ is offline
external usenet poster
 
Posts: 2
Default Adding controls to a userform at runtime

I would like to generate various controls on a skeleton userform (eg, the
number may vary with the occasion) and have tried
Private Sub UserForm_activate()
Stop
Dim obj As Object
Set obj = Me
Set obj = obj.Add("MSForms.CommandButton.1", "Butt1", True)

but when the form opens I receive the error message
Runtime error '-2147221005(800401f3':
Invalid class string

What am I doing wrong, please?