CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    14

    Enumerating control properties from add-in

    Hi,

    Does anyone know how to go about to access the properties of all the controls in a project?

    What I would like to do is to write an add-in that will take the name and some other properties of all the controls in the project and put them a text-file.

    This is getting frustrating, I know it should be possible, but I just can't get it to work. So I'm very grateful for any answers or hints.

    /Xplorer



  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Enumerating control properties from add-in

    If you use the Microsoft Visual basic Extensibility Object by setting a reference to VB5EXT.OLB in your add in you can enumerate the controls and properties thus:


    Dim ptyThis as VBIDE.property
    Dim ctThis as VBIDE.VBControl
    Dim frmThis as VBIDE.VBForm
    Dim cmpThis as VBIDE.VBComponent

    for Each cmpThis In VBE.VBProjects(1).VBComponents
    If cmpThis.Type = vbext_ct_VBForm Or cmpThis.Type = vbext_ct_VBMDIForm then
    set frmThis = cmpThis
    for Each ctThis in frmThis.VBControls
    Debug.print "Control - " & ctThis.Name
    for Each ptyThis in ctThis.Properties
    Debug.print "property - " & ptyThis.name
    next ptyThis
    next ctThis
    End If
    next cmpThis




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    14

    Re: Enumerating control properties from add-in

    Hi,

    Thank you for your answer, it was very useful.

    I also found a sample called "TabOrder" in MSDN that gave a few tips (it also proved to be a handy little add-in btw).

    /Xplorer



  4. #4
    Join Date
    Dec 2001
    Posts
    6,332
    As much as I tried, I could not get this to work for VB6. The most I get is "With block or object variable not set". I searched this forum, and google, but found no answers. The few code examples I ran into all had a syntax which was not recognized by vb6, and indeed, they were for vb5. I did find a reference to the fact that vb6 uses the extensibility object differently.

    Anyone?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured