Discussion:
Struggling with a path with a nightmare name
(too old to reply)
Styrmir Gunnarsson
2018-02-14 12:46:55 UTC
Permalink
Hi everybody

Been struggling the whole day with this simple script which basically just moves a file from one place to another. I am not completely new to vbscript and this what I have done:

Dim fs, source
Set fs = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

fs.MoveFile "W:\dcfs\DFSLinks\ftp_ikano_nu\ikb\dk1\Nordiccom\to_ikano\*.xls", "W:\finance\DK\MISC\COMMON\AFD Salg & Marketing\Afdelingen privat\Forsikring\2 step sales process\Back book\"

If Err.Number = 0 Then
MsgBox "Done"
ElseIf Err.Number = 53 Then ' File not found
MsgBox "Nothing to do"
ElseIf Err.Number = 76 Then ' Path not found
MsgBox "Target path not found"
Else
MsgBox "Unexpected Error " & Err.Number & " - " & Err.Description
End If

On Error Goto 0

The problem lies within the path I am moving the file to and I am beginning to think it's not the spaces but the & sign in it because of I replace it with "P:\Work\New folder" it works exactly as intended.

Can anyone suggest a solution? I have tried with double quotation marks on each site etc.

Thanks for reading :)

BR
Styrmir
Styrmir Gunnarsson
2018-02-14 14:27:47 UTC
Permalink
Nevermind, looks like it is working :)

Loading...