Consulting

Results 1 to 10 of 10

Thread: Setting Default Property in a Class Module

  1. #1
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778

    Setting Default Property in a Class Module

    I am using a Class Module to define a class. It has properties, but I would like to make one of those properties the default. How do I do that?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    In the VBIDE, export the class module.

    Open the exported file in a text editor.

    Look for the property Get for your target property and add this line

    Attribute Value.VB_UserMemId = 0

    So that the property will now be something like


    [vba]

    Property Get StartYear() As Long
    Attribute Value.VB_UserMemId = 0
    StartYear = mStartYear
    End Property
    [/vba]
    Last edited by Bob Phillips; 06-02-2007 at 12:25 PM.

  3. #3
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    many thanks

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Bad News. It apparently doesn't work on Mac.s

    I should mention someting in the Mac forum, but Excel 2004 doesn't have an Export option on the menu, so I'm not too surprised

    When I wrote my own export/import and followed those instructions. I could not see the added line, and the code ran as if there were nothing there.

    Bummer.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Thank you lucas and BlueCactus. That is a sweet utility for a Mac user.

    Unfortunatly, I can't get it to assign a property as the default.
    The module exports and imports fine, but the Default properties of custom classes may not be supported by Mac.

    I noticed something. I exported the module, inserted the line with Text Edit, saved the file and imported it. Viewed through the VB editor, the inserted line had been removed. The line count wasn't changed , but there were no (visible) characters. When I exported the modified module and inspected that new export with Text Edit, the inserted code was gone. Excel 2004 removed that instruction.

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I guess not everything about Mac is wonderful...

    sorry I just couldn't resist
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Quote Originally Posted by lucas
    I guess not everything about Mac is wonderful...
    Mac doesn't need every thing to be wonderful, just more things than a PC.

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Well, at its inflated price tag and its crippled functionality, I guess it needs something.

  10. #10
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Now, now, boys and girls!!!
    Semper in excretia sumus; solum profundum variat.

Posting Permissions

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