Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a Property or Method the Default in VBA. 1

Status
Not open for further replies.

PaulMcCulloh

Programmer
Feb 11, 2003
8
US
In VB6, you can use the Procedure Attributes/Procedure ID to set a Property or Method the Default. How can you do this in VBA? Is there an API call (or set of calls) that can be used?

thank you,
Paul McCulloh
 
Nooo, not an API call.

But there's a sneaky way of doing this:

1. Export your class module
2. Open the class module in Notepad
3. Add this line as the SECOND line of your Poreporty Get statement:
Code:
Attribute Value.VB_UserMemId = 0
4. Save module
5. Reimport Class module

NB - you won't see this line of code in the VBA Editor
NB2 - it might disappear when you edit/recompile the class module.

Check out this thread (similar question) for a link to an example: thread707-455187

Cheers
Nikki
 
Thanks so much, Nikki! Your method works perfectly, and I had no problems when recompiling the module.

I don't understand why they leave things like this out of VBA. I've only found a few things "left out" of VBA that you can do VB (there are probably many I don't know about...) -- but they're always things you need!

May I ask: How did you learn about this? I would love to be able to "get under the hood" more, but I don't know where to turn for a good education in what's really happening behind the scenes.

thanks,
Paul
 
Hiya paul,

I used to work as an IT Instructor, and before they'd allow me to teach my own class I had to sit through the courses. One of my colleagues teachingthe VBA course knew about this - and many other tricks - but I have no idea where he got it from ...

But's it's proven mighty useful on many occasions!

Cheers
Nikki
 
Hi Nikki,
Thanks for your reply. Well, good to know I'm not missing something really obvious. I'll have to dig around some more. It sure is a useful trick. Thank you again for your help!

take care,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top