"Copy Document and Its Dependencies (VBA)"

hi,

I tried "copy document and its dependencies (VBA)" example macro, but i got error.

example code:

Set swApp = Application.SldWorks

' Source path and file: disk:\one_folder_above_macro_folder\Models

source = swApp.GetCurrentMacroPathName

source = Left(source, InStrRev(source, "\") - 1)

source = Left(source, InStrRev(source, "\")) + "Models\"

sourcefile = "name_of_file.SLDASM"

' Target path: disk:\macro_folder

target = swApp.GetCurrentMacroPathName

target = Left(target, InStrRev(target, "\"))

I tried below code.


Set swApp = Application.SldWorks

' Source path and file: disk:\one_folder_above_macro_folder\Models

source = swApp.GetCurrentMacroPathName

source = Left(source, InStrRev(source, "D:\Old_Folder\") - 1)                   --error this line

source = Left(source, InStrRev(source, "D:\Old_Folder\")) + "Models\"

sourcefile = "Assembly_01.sldasm"

' Target path: disk:\macro_folder

target = swApp.GetCurrentMacroPathName

target = Left(target, InStrRev(target, "D:\New_Folder\"))

SolidworksApi macros