Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to specify file path as project file path?

heesu.kim96WY9
Participant

How to specify file path as project file path?

heesu.kim96WY9
Participant
Participant
hello.

Please understand that my English is not proficient.

Const sXLDoc As String = "C:Temp\BOM.xlsx"
Here, we want to specify the "Temp" path as the path where the project file is located. We need your help.
0 Likes
Reply
Accepted solutions (1)
365 Views
2 Replies
Replies (2)

Dev_rim
Advocate
Advocate
Accepted solution

Hi,

You can get the Project file path like this:

    Dim oDesignProjectMgr As DesignProjectManager = inventorApplication.DesignProjectManager
    Dim ipjFilePath as String = oDesignProjectMgr.ActiveDesignProject.FullFileName
    Dim ipjFolderPath as String = System.IO.Path.GetDirectoryName(ipjFilePath)
    Dim sXLDoc As String = ipjFolderPath & "\BOM.xlsx"

You should use your inventor application object at line 1 for "inventorApplication". If you are using VBA its "ThisApplication".

 "ipjFolderPath" is the path that you need.

I recommend you check if the file already exists in desired location, before save the file. If there is a file with same name it will be an error. You can check it manually also. But you want to check it programmitically here is the code:

 

    Dim oDesignProjectMgr As DesignProjectManager = inventorApplication.DesignProjectManager
    Dim ipjFilePath as String = oDesignProjectMgr.ActiveDesignProject.FullFileName
    Dim ipjFolderPath as String = System.IO.Path.GetDirectoryName(ipjFilePath)
    Dim sXLDoc As String = ipjFolderPath & "\BOM.xlsx"
    If System.IO.File.Exists(sXLDoc) Then
        'The file exists Do something else
        
    Else
        'the file doesn't exist So you are safe

    End If
    

 

I hope this will solve your problem.

Devrim

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards

heesu.kim96WY9
Participant
Participant
thank you.
Thanks for your help, problem solved.