Suppose you have built a macro that uses some INI and DATA files for input or output, located in the same directory. You have hard-coded the path into your DVB file, so that your macro knows where to look for these files.
The end-users decide to make the macro available on a network server drive. But the client PC's use different drive letters for this drive. Also, the IT department changes the directory name for the application. Result: the macro can't find the INI and DATA files.
Here's a solution:
Public Sub GetMyLocation()
Dim strDVBname As String, strDVBpath As String
strDVBname = VBE.ActiveVBProject.Name & "."
strDVBpath = VBE.ActiveVBProject.BuildFileName
strDVBpath = left(strDVBpath, InStr(strDVBpath, strDVBname) - 1)
Debug.Print strDVBpath
' e.g. strDVBpath will be "AnyDrive:\AnyDir\AnySubdir\"
' so your macro can access data files in this directory
' no matter where the directory is created.
End Sub
I hope this is of some use for some.