Get Inventor's macros directory location programatically (VBA)

Get Inventor's macros directory location programatically (VBA)

Anonymous
Not applicable
2,659 Views
2 Replies
Message 1 of 3

Get Inventor's macros directory location programatically (VBA)

Anonymous
Not applicable

Hi,

 

In my macro I use ini file to write and read some settings, so I need to know the (macros) file "Default.ivb" location, which is set in "Application Options" > "File" > "Default VBA project", because in this directory I want to save my ini file. 

 

How can I get directory path where is placed "Default.ivb" file by using VBA?

 

Best regards,

Marek

 

0 Likes
Accepted solutions (1)
2,660 Views
2 Replies
Replies (2)
Message 2 of 3

pball
Mentor
Mentor
Accepted solution

ThisApplication.FileOptions.DefaultVBAProjectFileFullFilename

 

This returns the full file name of the VBA script file. You'll have to strip the file name to get the folder.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 3 of 3

Anonymous
Not applicable

 Thanks for reply! This is a ready function that I wrote:

Function GetMacrosDirectory() As String 'returns Inventor's "Macros" directory: C:\Users\Public\Documents\Autodesk\Inventor 2018\Macros\
  Dim IvbFilePath As String
  IvbFilePath = ThisApplication.FileOptions.DefaultVBAProjectFileFullFilename 'returns: C:\Users\Public\Documents\Autodesk\Inventor 2018\Macros\Default.ivb
  GetMacrosDirectory = Left(IvbFilePath, InStrRev(IvbFilePath, "\"))   'get the directory path for the "Default.ivb" file
End Function

Best regards. Smiley Happy

Marek

 

0 Likes