The little block of code below is giving me fits. It generates an error 91, and I have tried a large number of solutions but I am stumped. I feel pretty sure that I am not handling object variable assignments properly but don't know how to fix it. Any help would be appreciated. The degger indicates that the error occurs on the "with .controls ("textbox1")" line but I don't see VBD ever being set to a value so I think that is where the problem starts.
Sub Change_Userform()
Dim VBP As VBIDE.VBProject
Dim VBC As VBIDE.VBComponent
Dim VBD As UserForm
Set VBP = ThisWorkbook.VBProject
Set VBC = VBP.VBComponents("Calc") 'this is my userform name
Set VBD = VBC.Designer
with VBD
with .controls("textBox1")
.value = "12345"
end with
end with
End Sub
Bookmarks