user9551155
user9551155

Reputation:

How to refer to a relative path in SolidWorks VBA

I am writing a macro in SolidWorks VBA that is supposed to open all the parts of an assembly and update their design tables. When the assembly and parts are copied to a new location, I want the macro to open the new (copied) parts in their new location. How do I refer to a relative path for the parts instead of an absolute path.

Or: How do I program VBA to change the file location of the parts to the current folder?

I've found some info on how this works in Excel VBA, yet I can't seem to translate this to SolidWorks VBA.

Dim folderpath As String
folderpath = Application.Activeworkbook.Path

I can't figure out with what I should replace "ActiveWorkbook" to get the location of the current assembly. Searching the object browser in SW VBA doesn't show anything usefull either.

Upvotes: 3

Views: 1599

Answers (1)

ehcanadian
ehcanadian

Reputation: 1784

You'll want to use swModel.GetPathName. Here's an example.

Upvotes: 2

Related Questions