References and functions? (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 20:31
Joined
Sep 21, 2011
Messages
14,217
Hi all,

When you find a piece of code that will do pretty much what you want, how do you identify what reference library is required.?

EG I just helped a user on another forum, and I used

Code:
Dim objClip as New DataObject
.
.
objClip.SetText strData
objClip.PutInClipboard

Now that requires MSForms library as all the experts would probably know, but for someone like me, how would you work that out.?

TIA
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,209
In the VBE do a search for that function using the Object Browser. It will show you the library containing that item.



The obvious flaw in that argument is that you need that reference to be installed before you can do the object browser search!
 

Attachments

  • Capture.PNG
    Capture.PNG
    7.5 KB · Views: 189

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:31
Joined
Feb 28, 2001
Messages
27,128
There are 3rd party utilities that will do that, use at your own risk, but search for "Find entry point in DLL" on the web and at least a couple will come up. I make NO guarantees.
 

Micron

AWF VIP
Local time
Today, 15:31
Joined
Oct 20, 2018
Messages
3,478
I'd wager that unless the Access versions are quite different, 99% of the libraries pertaining to objects, methods and properties from posted code will be installed so the suggestion on how to uncover that is a good one. As for custom dll's & such, they would be provided and documented where they originate from, but maybe not from "3rd party" sources.
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,209
One thing I forgot to mention earlier.
Some vba functions are normally hidden. The wizhook function is one of those.
To view these, you need to click 'Show Hidden Members' in the object browser.

However, those hidden functions can still be used even when hidden.
 

Micron

AWF VIP
Local time
Today, 15:31
Joined
Oct 20, 2018
Messages
3,478
is that an option only if you have hidden members?
I don't see it but I don't have that reference in most db's either.
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,209
Just click anywhere in the search results area to show the context menu as below.
Most libraries include hidden members which are shown in light grey font e.g. LoadFromText.
Hidden functions are fully functional but in general are not officially supported by MS.

 

Attachments

  • Capture.PNG
    Capture.PNG
    18.6 KB · Views: 149

Micron

AWF VIP
Local time
Today, 15:31
Joined
Oct 20, 2018
Messages
3,478
never had done that, however, I take it that the ones in light grey are the hidden ones since they're not in the list until un-hidden - but they sure look like Access functions and methods.

Classes1.jpg

Classes2.jpg


EDIT - I certainly struggle with inserting images in this forum. Will have to revisit topic to see why they mostly end up as links for me.
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,209
Correct.
You can have hidden classes (on the left) and hidden members (on the right)
So for example the standard Access library include a visible class Application which includes many hidden members including InsertText, IsMemberSafe, LoadFromText, SaveAsText, Wizhook etc
They are all standard Access functions & many are very useful but because they aren't officially documented, it can be hard to find out how to use them.
It also means they could in theory be removed by MS in a later version but most have existed for over 20 years so its unlikely they will be taken out

EDIT - Have a look at this thread for a tutorial on inserting inline images: https://www.access-programmers.co.uk/forums/showthread.php?t=194680
 

Mark_

Longboard on the internet
Local time
Today, 12:31
Joined
Sep 12, 2017
Messages
2,111
Gasman,

I'd personally put a comment in BEFORE you reference the object that tells you
Code:
'objClip REQUIRES MSForms Library. Check that its there before using.
Dim objClip as New DataObject
.
.
objClip.SetText strData
objClip.PutInClipboard

That should help if you have a new install and have your code hiccup on you.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:31
Joined
Sep 21, 2011
Messages
14,217
Thanks everyone,
Most of the time, it is mentioned 'You will need to install...' however, I already had that library in my test db, but the user did not. He was using API and Clipboard_SetData, but I was not going to find all the code required for that, so used the simple method.

After posting, I was wondering, when does the Missing reference get displayed?

I do comment my code as my memory is rubbish these days, but that tip is still a good one
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:31
Joined
Sep 21, 2011
Messages
14,217
There are 3rd party utilities that will do that, use at your own risk, but search for "Find entry point in DLL" on the web and at least a couple will come up. I make NO guarantees.

I think I used something like that in another thread when trying to help someone, but wouldn't that require you knowing the dll.?

I am talking about using a function xx that I found via Google to do what I want, but it is not mentioned that you need a particular reference that contains it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:31
Joined
Feb 28, 2001
Messages
27,128
After posting, I was wondering, when does the Missing reference get displayed?

Depending on launch conditions and method, it CAN happen that at launch you are notified of missing references. However, it is ALSO possible that you would not be able to see those notices if the app is partly secured.

If you are the developer and something is missing, you get an "unknown function" error when compiling. However, Access secured apps that are distributed to users are most often pre-compiled so THEY won't get that notice. If you have the app locked down enough, they might not see the launch warning. So what I did is, behind the scenes in my opening form, I had code in the Form_Open routine that checked Application.References to see what was in my reference list, and I had an actual table of needed applications.

https://docs.microsoft.com/en-us/office/vba/api/access.application.references

I think I used something like that in another thread when trying to help someone, but wouldn't that require you knowing the dll.?

What it would require depends on who made the tool. You could use the tool to make a list of what was in each DLL you had, and it would be easy enough to write a batch script to find them. But yes, sometimes it IS hard to find a starting point.
 

Users who are viewing this thread

Top Bottom