Hello,
i have Userform1 with a few CommandButtons. When i run my VBA code, it return Error 91 - object variable or with block variable not set
What would i like to do:
1. I would like to count number of controls on Userform1
2. I would like to do something with CommandButton1 whitch is placed on Userform1 (change Caption, position ...)
Please tell me why the Error 91 occurs in this VBA code and how to repair it?
Dim Button As CommandButton
Debug.Print UserForm1.Controls.Count
Set Button = ThisWorkbook.VBProject.VBComponents("UserForm1").Designer("CommandButton1") - here is error 91 object variable or with block variable not set
With Button
.Caption = "New button"
.Width = 72
.Height = 24
.Left = 12
.Top = 58
End With
Thanks for reply
Bookmarks