TheAntisocial
New Member
- Joined
- Sep 7, 2009
- Messages
- 33
- Office Version
- 2013
- Platform
- Windows
Hi all.
I have the following code.
I want to copy a file from folder 1 to folder 2 and then open folder 2.
Folder 2 will change depending on the user as it's linked to their payrole, hence the use of the Dims and not just the filepath.
The code runs with no error messages, and folder 2 opens, but the file is not being copied.
If I purposely make the filepath wrong then it errors saying it can't find the file.
If I don't use dFilePath and paste the cell contents/filepath it refers to directly into the code then in it copies the file.
Can anyone see where im going wrong? I'm assuming the problem is with dFilepath but i can't work out what.
All help is very much appreciated.
I have the following code.
Code:
Sub MoveFile()
Dim dFolderPath As String
Dim dFilePath As String
dFolderPath = Range("FolderPath").Value
dFilePath = Range("FilePath").Value
FileCopy "U:\CS Data\01 Live\2014-2015\Calendars\Cust Serv Calendar.lnk", "dFilePath"
Shell "C:\WINDOWS\explorer.exe """ & dFolderPath & "", vbNormalFocus
End Sub
I want to copy a file from folder 1 to folder 2 and then open folder 2.
Folder 2 will change depending on the user as it's linked to their payrole, hence the use of the Dims and not just the filepath.
The code runs with no error messages, and folder 2 opens, but the file is not being copied.
If I purposely make the filepath wrong then it errors saying it can't find the file.
If I don't use dFilePath and paste the cell contents/filepath it refers to directly into the code then in it copies the file.
Can anyone see where im going wrong? I'm assuming the problem is with dFilepath but i can't work out what.
All help is very much appreciated.