Make folder where assembly is created, not where the part is created:VB code

Hello all

I am making my debut in macros. I recently created a program to save DXF of sheet metal part into thickness wise separate folders. With the help of forum, i created the macro.​. Now the problem is:

The location where the 'DXF' folder is to be created uses the below code

FilePath = swModel.GetPathName

This is the location of the model(sld.prt). Is there a way, i can get the location of the assembly through which the part is referenced. Because there are some parts that get used in most of the assemblies and are inserted in assembly from the root folder only(while assembly is located in different folder).

This will make the DXF in folder where assembly is created not where the part is located.

Can this happen with a precondition that, the main assembly must be opened or any such sort of condition.

I am sure there is way out, please help

Thanks in Advance

SolidworksApi macros