VBA program path

Discussion in 'AutoCAD' started by bhl, Jan 13, 2005.

  1. bhl

    bhl Guest

    Hi

    Is it possible to get VBA path from where it was loaded into autocad?

    Birger
     
    bhl, Jan 13, 2005
    #1
  2. bhl

    Matt W Guest

    You'll need to add a reference to: Microsoft Visual Basic for Applications
    Extensibility 5.3
    Then add the following code to a module.

    Sub test()
    Dim VBInstance As VBIDE.VBE
    Set VBInstance = ThisDrawing.Application.VBE
    MsgBox VBInstance.ActiveVBProject.FileName
    End Sub

    This will give you the full file name, including the path.
     
    Matt W, Jan 13, 2005
    #2
  3. bhl

    ClementZheng Guest

    VBE.ActiveVBProject.FileName
     
    ClementZheng, Jan 17, 2005
    #3
  4. bhl

    David Urban Guest

    hello

    this works when I am only using one VBA program. When I use it then use
    another VBA program then back to the program that uses this code it
    wants to return the name of the other program. Not good. any suggestions.

    David Urban
     
    David Urban, Mar 28, 2005
    #4
  5. bhl

    PepaU Guest

    Hallo,
    you can test a name of your project
    (see example)

    'gives dvb dir
    Public Function getDVBDir(dvbName As String) As String
    Dim selDir As String
    Dim selFile As String
    Dim ipr As Long
    On Error Resume Next
    For ipr = 1 To Application.VBE.VBProjects.count
    If UCase(Application.VBE.VBProjects(ipr).name) = UCase(dvbName) Then
    selFile = Application.VBE.VBProjects(ipr).fileName
    selDir = predLom(selFile)
    getDVBDir = selDir
    End If
    Next ipr
    End Function

    Regards
    Josef
     
    PepaU, Mar 29, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.