jolivanes
Well-known Member
- Joined
- Sep 5, 2004
- Messages
- 3,186
- Office Version
- 2013
- 2007
- Platform
- Windows
If I use this
The outcome is
M15 = "D:\Music\My MusicMP3\French\Adamo - A demain sur la lune.mp3"
M16 = "C:\Temp Music\Adamo - A demain sur la lune.mp3"
However, when I change the code to
I get an Error 52 (Bad filename or number) and it highlights
I have tried on 2 different computers (2003 and 2007) with the same results.
I checked all the cells and none have leading/trailing spaces (ran TRIM on all of them)
When hardcoding the folder and file names in the code, it works as expected.
Can someone tell me where I went wrong please.
Thank you very much.
John
Code:
Sub CopyToDifferentFolder()
Dim SrceFile
Dim DestFile
SrceFile = """" & ActiveCell.Offset(, 3).Value & "\" & ActiveCell.Value & " - " & ActiveCell.Offset(, 1).Value & """"
DestFile = """" & Range("M2").Value & "\" & ActiveCell.Value & " - " & ActiveCell.Offset(, 1).Value & """"
Range("M15").Value = SrceFile
Range("M16").Value = DestFile
End Sub
M15 = "D:\Music\My MusicMP3\French\Adamo - A demain sur la lune.mp3"
M16 = "C:\Temp Music\Adamo - A demain sur la lune.mp3"
However, when I change the code to
Code:
Sub CopyToDifferentFolder()
Dim SrceFile
Dim DestFile
SrceFile = """" & ActiveCell.Offset(, 3).Value & "\" & ActiveCell.Value & " - " & ActiveCell.Offset(, 1).Value & """"
DestFile = """" & Range("M2").Value & "\" & ActiveCell.Value & " - " & ActiveCell.Offset(, 1).Value & """"
FileCopy SrceFile, DestFile
End Sub
I get an Error 52 (Bad filename or number) and it highlights
Code:
FileCopy SrceFile, DestFile
I have tried on 2 different computers (2003 and 2007) with the same results.
I checked all the cells and none have leading/trailing spaces (ran TRIM on all of them)
When hardcoding the folder and file names in the code, it works as expected.
Can someone tell me where I went wrong please.
Thank you very much.
John