Forum Discussion

DanMcG's avatar
DanMcG
Brass Contributor
Feb 11, 2021

finding the userform.designer hidden commands

i have searched the internet but have found no relevant data on application.vbe.vbcomponents("userform1").designer methods and properties. can someone steer me in the right direction?

 

i know from books in the early 2000's mention that you can set a control, create a control or remove a control. but intellisense dies after i type in  .designer. so there is no help there?

 

any wise sages know?

2 Replies

  • JMB17's avatar
    JMB17
    Bronze Contributor

    DanMcG 

     

    I'm not familiar with designer or if it can be used to accomplish what I think you are trying to do.

     

    I've also not created many dynamic userforms, so I'm far from an expert on the subject, but if you want to add, remove, or modify controls, then I believe you should be able to create an object reference to your userform before you show it and add/remove/modify it's controls using the methods of the userform and it's controls collection.

     

    When working with the control itself, you may have to dim it as a control to get some methods you want and intellisense won't display the methods/properties specific to that type of control, but you may still be able to use them.

     

    This page will probably be a good reference (especially for the control ID's under the add method):

     

    https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/reference-microsoft-forms

     

    Private Sub Macro1()
         Dim uForm As UserForm1
         Dim newLabel As MSForms.Control
         
         Set uForm = New UserForm1
         Set newLabel = uForm.Controls.Add("Forms.Label.1", "Label1", True)
         
         With newLabel
              .Caption = "Test"
              .Move 20, 20, 40, 10
         End With
         
         uForm.Show
         
    End Sub

     

     

  • DanMcG's avatar
    DanMcG
    Brass Contributor

    any microsoft guru's that are surfing these formus, would like to hear what you have to say...

Resources