Solidworks VBA save as new name

4.7k views Asked by At

I am currently generating a solidworks part file name from a text document for a batch "rename" of the documents. This assigns sequential numbers to them which i then save each part in a folder as. I have been trying to figure out a method for the new file names to be referenced in the assembly they were a part of.

For saving the document I am using :

swModel.SaveAs3 "" & FileName & "", 0, 0

I have no issue creating all the files in a batch but I could not seem to find a method of apply this save in such a way that any open documents that it is referenced in change to referencing the new part name.

Edit: I figured out a serviceable solution using some of the information held in this link:

help.solidworks

Using the pack and go functionality in solidworks avoids having to deal with the references as they are already handled by the process itself Hope this helps.

1

There are 1 answers

0
GamingHeaven On

Try the below approach:

Dim FileName As String
FileName = "blablabla" & Variable & "blablabla"
swModel.SaveAs3 ("C:\User\Username\Desktop" + FileName + ".SLDPRT", 0, 1)

Variable = Variable + 1
'continue with your loop