|
-
October 23rd, 2001, 08:26 AM
#1
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
-
October 23rd, 2001, 09:44 AM
#2
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.
-
October 24th, 2001, 04:15 AM
#3
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
-
January 23rd, 2004, 11:00 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|