Click to See Complete Forum and Search --> : Enumerating control properties from add-in
Xplorer
October 23rd, 2001, 08:26 AM
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
Clearcode
October 23rd, 2001, 09:44 AM
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.
Xplorer
October 24th, 2001, 04:15 AM
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
WizBang
January 23rd, 2004, 10:00 AM
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?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.