PDA

View Full Version : Solved: Export properties of VBA-object?



Steiner
07-01-2004, 10:31 PM
Hello all,

this is a overall VB-Q (I did not find a solution for VB 6 nor VBA :mad: ):
I want to export all properties of an object at runtime. So let's say I have:
Private Sub CommandButton1_Click()
Dim myTxt As TextBox
Set myTxt = TextBox1
Stop
End Sub


Now I can view all properties of myTxt in the local window. But how can I export them in a way, that another program could read it (so PrtScr is not an option)??:confused:

Thanks
Daniel

Anne Troy
07-02-2004, 10:34 AM
I moved it to the appropriate forum, Daniel. :)

mark007
07-02-2004, 04:31 PM
If you know what object you are looking at, then the answer is fairly simple. Otherwise, however, I think it would be harder. I can't think of any way to easily loop through every property of an object, so I'm thinking the only way would be to read the info from the type library, which I can't say I've tried before. That, plus I'm :drunkard: as it's late Friday night, and I'm inclined to ask why do you want to do this?

:)

Steiner
07-05-2004, 05:05 AM
Well, basically I'm looking for a way to export all properties of 2 controls (at runtime) to Excel to easily compare them. Because one of them does work, another one does not.

But the original purpose is not so urgent anymore, but I was wondering, whether there is a way to export those properties (maybe a loop or something like that).

Daniel

Juan Pablo Gonz?lez
09-22-2004, 07:14 AM
Try downloading the Type Lib utilities file available at Chip's site:

http://cpearson.com/excel.htm

From the site:


Download XLTLI - Type Lib Utilities (http://cpearson.com/Zips/TLIUtils.ZIP)
This download provides about 20 VBA utility functions for working with the TypeLib Information object library, which is used to read type libraries. TypeLib Info is the "engine" behind the VBA Object Browser, and this library gives you programmatic access to type libraries, allowing you to determine the various arguments for methods, the symbolic names of constants, the methods of an object and so on. Complete documentation is in the VBA code of this workbook. This code is for advanced VBA programmers, not novices. An advanced version of XLTLI is available for commercial customers.

Steiner
09-28-2004, 05:29 AM
Thanks for the tip Juan :) , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums :roll: ).

I'll try to find a way around that...

Howard Kaikow
10-03-2004, 06:43 AM
Thanks for the tip Juan :) , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums :roll: ).

I'll try to find a way around that...
I have not looked at Chip's stuff, but I'll make a few comments:

1. It's not hard to get a list of controls, but getting a list of the properties for each control (without going thru a type library) is likely impossible.

2. Unless you have an absolute need to use Excel 97 for a particular reason, you should upgrade to a more recent version of Office if only to be able to use the extra goodies in VB/VBA 6.

Steiner
10-04-2004, 12:22 AM
I'd like to upgrade, too, but unfortunately that's not my decision...

Juan Pablo Gonz?lez
10-05-2004, 11:28 AM
Thanks for the tip Juan :) , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums :roll: ).

I'll try to find a way around that...Not a huge deal... just need to change all the enums to public constants.

Steiner
10-12-2004, 12:49 AM
Thank you Juan! I'll try to test / use this as soon as I can look over the pile of work on my desk again which may take a while...

Nevertheless, I'll mark this thread solved.

staffel
02-15-2005, 10:03 AM
Do not use

myBox as TextBox

or something like that. Say
myBox as Object

and use the basic (classes/types/properties) to loop through all objects and classes. (parent, class, name, next, text, caption, property, ...) you can hangle through to check all properties of all available and connected objects.