Excel Hints

Results 1 to 11 of 11

Thread: Solved: Export properties of VBA-object?

  1. #1
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location

    Question Solved: Export properties of VBA-object?

    Hello all,

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

    [/VBA]
    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)??

    Thanks
    Daniel

  2. #2
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Allentown, Pennsylvania
    Posts
    2,528
    Location
    I moved it to the appropriate forum, Daniel.
    ~Anne Troy

  3. #3
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    619
    Location
    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 as it's late Friday night, and I'm inclined to ask why do you want to do this?

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net | Professional Office Developers Association

  4. #4
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    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

  5. #5
    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
    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.
    Regards,

    Juan Pablo Gonz?lez

  6. #6
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    Thanks for the tip Juan , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums ).

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

  7. #7
    Quote Originally Posted by Steiner
    Thanks for the tip Juan , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums ).

    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.

  8. #8
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    I'd like to upgrade, too, but unfortunately that's not my decision...

  9. #9
    Quote Originally Posted by Steiner
    Thanks for the tip Juan , but unfortunately I can't yet get it to work with Excel 97 (that does not support Enums ).

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

    Juan Pablo Gonz?lez

  10. #10
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    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.

  11. #11

    Cool

    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.

Posting Permissions

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