• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Error running VBS

I am trying to copy files to FolderA then move them to FolderB, but I get an VBScript error:




LINE 11
CHAR: 9
ERROR: Bad File name or number
Code 800A0034

See CODE BELOW...

strSourceFolder = "\\10.41.40.119\ercharts$"
strTargetFolderA = "\\10.41.40.119\ercharts$"
strTargetFolderB = "\\10.41.32.139\rootsftp$\MarinaMBS"

If Right(strSourceFolder, 1) <> "\" Then strSourceFolder = strSourceFolder & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objSource = fso.GetFolder(strSourceFolder)
For Each oFile In objSource.Files
    strFirst8 = Left(oFile.Name, 8)
    If Not fso.FolderExists(strTargetFolderA & strFirst8) Then
        fso.CreateFolder strTargetFolderA & strFirst8
    End If
    fso.copyfile strSourceFolder & oFile.Name, strTargetFolderA & strFirst8 & "\"
    fso.MoveFile strSourceFolder & oFile.Name, strTargetFolderB & strFirst8 & "\"
Next

Open in new window

0
epicazo
Asked:
epicazo
1 Solution
 
RobSampsonCommented:
Hi, change this:
fso.CreateFolder strTargetFolderA & strFirst8

to this:
fso.CreateFolder strTargetFolderA & "\" & strFirst8

Rob.
0
 
jorgedeoliveiraborgesCommented:
Put a new Line 11 in order to debug, please.
msgbox strTargetFolderA & strFirst8
0
 
epicazoAuthor Commented:
thank you
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now