Problem saving to a parent folder with my solidworks macro

Hello

I'm looking to save my pdf, dwg, dxf in the root of the parents folder. But I don't know the code to do that. Currently my macro creates the pdf folder if it doesn't exist and saves the pdf in it, but it is created in the root of my drawing and I would need it to be created in the parent folder.

 

I hope I have been clear attached my current registration code.

Kind regards
Mathieu


macro_enregistrement_multiformat.txt

I don't know anything about macros, I'm just starting to get interested in them.

On the other hand I found this in a forum: http://forum.excel-pratique.com/excel/trouver-le-nom-du-dossier-parent-du-fichier-excel-t19755.html

If it can help you?

Hello

Try like this:

'Retrieving the home
directory dossier_base = Left(path, Len(path) - Len(nom_fichier) - 7)

'Retrieving the parent directory

Dim dossier_parent As String
ChDir (
)
ChDir ".."
chemin = CurDir(
dossier_base dossier_base)

 

Then in each file type:

longstatus = Part.SaveAs3(dossier_parent & "DWG\" & nom_fichier & " - " & revision & ". DWG", 0, 0)

 

See you

Thank you for your answer but I have a hard time modifying this macro myself.

 

I did it a while ago and I'm having a hard time getting back into it and especially a lack of time.

I can't do that now.

Can we talk about it again tonight?

Yes without any worries I thank you for your answers remrem.

I tried to include your lines of code but it doesn't work I must have made a mistake if you are more successful than me it will be with pleasure that I will wait for your answer.

2 Likes

Hello

Here is the updated macro in PC.


macro_dossier_sup.txt
1 Like