Jump to content

Determine the File Path or GUID to a VBA Reference Library


Recommended Posts

Posted

Does somebody knows how to set programatically the correct Guid for a VBA Reference Library, I am having problem when running a macro in diferent computer because the have different versions of Excel (2003 and 2007).

I read something to set the guid inside excel

http://www.vbaexpress.com/kb/getarticle.php?kb_id=267

, but I don'd know how to set it in Autocad.

 

Thanks in advance if somebody can help me.

Posted
Does somebody knows how to set programatically the correct Guid for a VBA Reference Library, I am having problem when running a macro in diferent computer because the have different versions of Excel (2003 and 2007).

I read something to set the guid inside excel

http://www.vbaexpress.com/kb/getarticle.php?kb_id=267

, but I don'd know how to set it in Autocad.

 

Thanks in advance if somebody can help me.

The same way in AutoCAD just add reference I commented below

into your project and save them before running

Option Explicit
' requre reference to:
' Microsoft Visual Basic For Applications Extensibility 5.3

Sub LoadRef()

   Dim refs As References
   Set refs = ThisDrawing.Application.VBE.activeVBProject.References
   Dim guid As String
   guid = "{00020905-0000-0000-C000-000000000046}"
   refs.AddFromGuid guid, 1, 0
   Dim ref As Reference
   'debug only:
   For Each ref In refs
   MsgBox ref.FullPath
   Next
     
End Sub

 

~'J'~

Posted

thanks Fixo !

I disabled the Excel Library and Load it with the routine and works really good!!

this is how it looks

 

 

Private Sub LoadRef()
   Dim refs
   Dim ref

   Set refs = ThisDrawing.Application.VBE.activevbproject.references
   Dim guid As String
   guid = "{00020813-0000-0000-C000-000000000046}" 'GUID for Excel
   
   On Error Resume Next
   refs.AddFromGuid guid, 1, 0
   If Err.Number <> 0 Then
       On Error GoTo 0
   End If



End Sub

 

The only thing is I don't know why doesn't recognize the Reference variables (Dim refs as Reference), everithing else is working good.

 

The same way in AutoCAD just add reference I commented below

into your project and save them before running

Option Explicit
' requre reference to:
' Microsoft Visual Basic For Applications Extensibility 5.3

Sub LoadRef()

   Dim refs As References
   Set refs = ThisDrawing.Application.VBE.activeVBProject.References
   Dim guid As String
   guid = "{00020905-0000-0000-C000-000000000046}"
   refs.AddFromGuid guid, 1, 0
   Dim ref As Reference
   'debug only:
   For Each ref In refs
   MsgBox ref.FullPath
   Next

End Sub

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...