Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: fullevent

Hi @fullevent @moraesorlando 

 

I had a look at the code and I think it's just a missing backslash in the destinationpath that gives the error...

The folderbrowserdialog returns a folderpath without a backslash at the end.

 

I added it here and I think it should work now.

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
If Not ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then
    MessageBox.Show ("No assembly open..", "KrA")
    Exit Sub
End If
    
Dim origin_path As String, new_path As String, user_input As String, tmp_str As String
Dim sFilesToCopy(9) As String
    
user_input = InputBox("What is the new numebr", "YYYY-XXX", "")
If Len(user_input) <> 8 Then
    MessageBox.Show ("Invalid input..", "KrA")
    Exit Sub
End If
    
origin_path = Left$(oDoc.FullFileName, InStrRev(oDoc.FullFileName, "\"))

Dim folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog()
Dim path As String = ""
If (folderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
    new_path = folderBrowserDialog1.SelectedPath
Else 
	Return
End If

If new_path = "" Then
    MessageBox.Show ("User cancelled out of dialog", "KrA")
    Exit Sub
End If

sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt"
sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg"
sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt"
sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg"
sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt"
sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg"
sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt"
sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg"
sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt"
sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg"

For i = 0 To 9
    tmp_str = "DEPT-" & user_input & Right$(sFilesToCopy(i), Len(sFilesToCopy(i)) -13)
    Call ThisApplication.FileManager.CopyFile(origin_path & sFilesToCopy(i), new_path & "\" & tmp_str) ' Added "\"
Next

MessageBox.Show ("I hope you like it", "KrA")