Project reference list

Project reference list

grobnik
Collaborator Collaborator
1,432 Views
1 Reply
Message 1 of 2

Project reference list

grobnik
Collaborator
Collaborator

Hi to all,

I have a simple procedure made on Excel, for exporting some object reference point in Autocad.

Unfortunately not all team has the same machine with the same software versions, so I would like to have a list of project reference, in order to customize some declaration in the correct way.

 

I found the below procedure, that I'm trying to run in excel VBA, but I got an error that I'm not able to understand the reasons, so I'm searching help in this forum.

Ref = Application.VBE.ActiveVBProject.References
For Each Ref In ActiveWorkbook.VBProject.References
    RefName = Ref.Name
    RefDesc = Ref.Description
    RefPath = Ref.FullPath
Next

Error got is Run Time error 1004.

Thank you to all.

0 Likes
1,433 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

Firstly, your code looks odd:

 

Ref = Application.VBE.ActiveVBProject.References

Meaning varaibale Ref is type of VBIDE.References (a collection of VBIDE.Reference)

 

But in 

For Each Ref In ActiveWorkbook.VBProject.References

You use it as type of VBIDE.Reference.

 

I guess you did not set "Option Explicit" in your VBA module, which is bad practice.

 

Now, come to the error 1004, which is security error: Excel (or other MS Office Application) does not allow Macro to access VBA object model by default. You must explicitly enable it in Trust Center menu "File->Options->Trust Center->Macro Settings" and then check the box of "Trust access to VBA project object model".

 

By the way, I do not see how using VBIDE library would help you to run a VBA project that has referenced libraries, which may not available in other computers. To handle that kind of issue, you would use late binding and hope other computers have the same version of the referenced libraries, or different but binarily compatible versions. 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes