Good morning, a coworker of mine asked me to take a look at his VBA for Solidworks and I'm stumped as to what the issue is. Basically, he is searching through old solidworks drawings to find ones relevant to a new project he is working on. If he finds one that is relevant, he uses a macro to make a copy of that drawing, move it to the folder for the new project, close the old file, and open the new one. The macro is as following
Sub Move_Copy()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
'Where the Copy Files are going
DestinationFolder = "\\SERVER\FOLDER\subfolder"
'Gets full path name of current file that is open
MyPath = swModel.GetPathName
'Gets File Name with extension
CurrentOpenFile = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)
'This copies the file and moves it
Call FSO.CopyFile(MyPath, DestinationFolder & CurrentOpenFile, True)
'This Closes the Current Document
swApp.QuitDoc CurrentOpenFile
'This opens the moved file
swApp.OpenDoc6 DestinationFolder & CurrentOpenFile, swDocDRAWING, swOpenDocOptions_Silent, "", ERRORS, WARNINGS
End Sub
The line that is bugging for him is
Call FSO.CopyFile(MyPath, DestinationFolder & CurrentOpenFile, True)
Any ideas? Thanks