0

I have a problem where I have a macro which was saved without connecting to any references, can I know how to know which object belongs to which reference.

for example:

This picture here shows the references currently connected to the project

but when I try to run the code it shows a compile error as "user type not defined"

The declarations in code

there are many such declarations in code, I don't know which declaration belongs to which library.

so can I know which reference is not connected.

Storax
  • 11,158
  • 3
  • 16
  • 33
tls
  • 11
  • 2
  • 1
    First of all, a declaration `Dim oProducts, oProducts1 as Products` is correct but `oProducts` will be of type `Variant` and `oPproducts1` will be of type `Products`. This is a typical misunderstanding of VBA beginners. Secondly, I do not think that anyone but you can know which reference is the right one. Even if you find the type `Products` in one of the libraries it could be contained in one of the others as well. So, you need to find out and afterwards you should add a full reference when declaring it – Storax Sep 28 '22 at 09:02
  • You could open the documentation and search to which reference/lib a type belongs. – Shrotter Sep 28 '22 at 09:04
  • 1
    You need to use the object browser. Search for the object in the line causing the problem. – freeflow Sep 28 '22 at 09:04
  • @freeflow That will only be a hint. A user type could have the same name in diffferent libraries. The developer need to know what the code is doing. If he doesn't .... If it is code from someone else you are in trouble anyway ;-) – Storax Sep 28 '22 at 09:09
  • @Storax If there were multiple objects with the same name then you would expect the use of the object to be qualified by the library/dll to which it belonged. If it isn't then it will be the first referenced lib that contains the name that will the the one being used. Very very bad developer conde in this case. – freeflow Sep 28 '22 at 13:31
  • @freeflow Yes, right , the code really leaves room for improvement ;-) – Storax Sep 28 '22 at 13:57

0 Answers0