Thanks for the help jenuary. I looked at the example but unfortunately I can't take advantage of it.
from what I understood you do not change the path of the equation file inside the part file.
I still attach the macro that I did, so I can try it when you have availability.
towards the end I entered the instruction "if my extention=txt.then goto 15" because only by canceling the text file equations, the macro works and replaces the first 2 characters of the names of each part, together or drawing; If not, if I comment the "if" instruction, copy the same names in the folder without changing anything.
I apologize if the code I created is not done very well.. thanks anyway for the availability.
private sub commandbutton1_click()
'sub packandgo()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swmodeldocext as sldworks.modeldocextension
dim swpackandgo as sldworks.packandgo
dim openfilepath as string
dim openfilename as string
dim savepath as string
dim savename, v3, v7, v8, v9, v10, v11, v13, v14 as string
dim myfilename as string
dim myextension as string
v1, v2, v4, v5, v6, v12, v15 as variant
dim pgfilenames as variant
dim pgfilestatus as variant
dim status as boolean
dim statuses as variant
dim i as long
v15 = 2 'n° of letters to be removed to the name
openfilepath = "c:\users\user\desktop\complesivo tramoggia.sldasm"
savepath = "c:\users\user\desktop\temp\"
set swapp = application.sldworks
set swmodel = swapp.opendoc(openfilepath, swdocassembly)
'set swmodel = swapp.activedoc
openfilepath = swmodel.getpathname
openfilename = mid(openfilepath, instrrev(openfilepath, "\") + 1, instrrev(openfilepath, ".") - instrrev(openfilepath, "\") - 1)
set swmodeldocext = swmodel.extension
'get pack and go object
set swpackandgo = swmodeldocext.getpackandgo
'includes any drawings
swpackandgo. includedrawings = true
status = swpackandgo.getdocumentnames(v1)
v2 = instrrev(v1(i), "\") + 1 'n° of famines up to the last slash
v3 = mid(v1(i), v2) 'I press the string to begin with n°v2 characters
v4 = len(v1(i))) I count the number of total characters
v5 = len(v3) 'count the number of characters of the striga v3
v6 = v4 - v5'n° of characters before part of the percrso
v7 = mid(v1(i), 1, v6)'s first part route
'set folder where to save the files
status = swpackandgo.setsavetoname(true, savepath)
'get files path
status = swpackandgo.getdocumentsavetonames(pgfilenames, pgfilestatus)
for i = 0 to ubound(pgfilenames)
myfilename = mid(pgfilenames(i), instrrev(pgfilenames(i), "\") + 1, instrrev(pgfilenames(i), ".") - instrrev(pgfilenames(i), "\") - 1)
myextension = right(pgfilenames(i), len(pgfilenames(i) - instrrev(pgfilenames(i), ".") + 1)
if myextension = ".txt" then pgfilenames(i) = ""
if myextension = ".txt" then goto n15
v11 = len(v1(i))) 'I count the number of current string total characters
v9 = len(myfilename) 'n° characters name
v16 = right(myfilename, v9 - v15) 'stringa remaining characters of the name
v10 = len(myextension) 'n° file extension characters
v8 = v11 - v6 - v9 - v10 'n° characters to be taken only if > of zero
v12 = mid(v1(i), v6, v8)
if v8 = 0 then goto n10
v13 = right(v12, v8 - 1)
v14 = v13 + "\"
N10:
pgfilenames(i) = savepath & v14 & "55" & v16 & myextension
'debug.print & pgfilenames(s)
n15:
next
'set files path
status = swpackandgo.setdocumentsavetonames(pgfilenames)
'
'pack and go
statuses = swmodeldocext.savepackandgo(swpackandgo)
end