View Full Version : File Copy - Strange Problem - Bad File Error


chaostheory
11-04-2008, 06:50 AM
I have a script doing a lot of things, but the last step is what im getting the problem on and its bugging the crap out of me. I pasted all the relevant code below. What is happening is on the last file copy, im getting a bad file name or number. If i copy and paste the direct path to the folder when i open it, its below. Here are the values that are being stored in the variables. Is there something funny about using a variable to specifiy the full path and file name?

workdir = 378Y005892_7.5x8.00
workpath = Z:\_AC_LBP\Database\Characterization-Raw Laserguage Data\
workfile = 05892
nebtemp = 03
nebfile1 = "Y:\Nebulizer Pictures 2008\11-03-08 11:30am\CompositeLeakData.txt"
nebfile2 = "Y:\Nebulizer Pictures 2008\11-03-08 11:30am\CompositeLeakDataSummary.txt"

Full Path when opened in explorer-
Y:\Nebulizer Pictures 2008\11-03-08 1130am



workDir = (Range("d4").Value & "_" & Range("H6").Value)
workPath = "Z:\_AC_LBP\Database\Characterization-Raw Laserguage Data\"
MkDir (workPath & workDir)
ChDir (workPath & workDir)
workFile = Right(Range("D4"), 5)
nebtemp = Left(Range("h7").Value, 4)
nebtemp = "0" & Right(nebtemp, 1)
nebFile1 = "Y:\Nebulizer Pictures 2008\" & Left(Range("h7"), 2) & "-" & nebtemp & "-" & Right(Range("h7"), 2) & " " & Range("h8") & "\" & "CompositeLeakData.txt"
nebFile2 = "Y:\Nebulizer Pictures 2008\" & Left(Range("h7"), 2) & "-" & Mid(Range("h7"), 5) & "-" & Right(Range("h7"), 2) & " " & Range("h8") & "\" & "CompositeLeakDataSummary.txt"
ActiveWorkbook.SaveAs (workPath & workDir & "\" & workFile & "-characterization.xls")
FileCopy ("I:\_AC Samples\Characterization\" & Range("d4") & ".csv"), (workPath & workDir & "\" & Range("d4") & ".csv")
FileCopy ("I:\_AC Samples\Characterization\" & Range("d4") & "-plane.csv"), (workPath & workDir & "\" & Range("d4") & "-plane.csv")
FileCopy (nebFile1), (workPath & workDir & "\" & "CompositeLeakData.txt")
FileCopy (nebFile2), (workPath & workDir & "\" & "CompositeLeakDataSummary.txt")
Range("E10").Value = "Done!"

boblarson
11-04-2008, 04:44 PM
Your problem is in nebFile1 and nebFile2 -

You have 11:30am as part of it and you can't have a colon : as part of a file name.

chaostheory
11-05-2008, 03:51 AM
Your a wizard...i knocked my head off the wall for an hour trying to figure out why it wouldnt work when everything "looked" right, but you are 100% right, i forgot to remove the ":" from the foldername.

Thanks so much. Sometimes it just takes someone elses eyes to see it :)