mark hansen
Well-known Member
- Joined
- Mar 6, 2006
- Messages
- 534
- Office Version
- 2016
- Platform
- Windows
I'm trying to do something that I thought was straight forward. I'm trying to move and rename a file from one folder to another. After doing the Google search I found:
On Ron de Bruin web site. This give me an Error 5 Invalid procedure error
Now I'm the trying the FileCopy and using Ron's example of
I came up with the following for my code
Which give me the error
The MsgBox shows - (under type in the Watch box is "Variant/string" for OldName and "String" for NewName. )
OldName = "\\{servername}\pad\Coding\IPR Deficiency\Chart Deficiency information\Data Files\Testing.txt"
NewName = "\\{servername}\pad\Coding\IPR Deficiency\Chart Deficiency information\Data Files\Old Import Files\20180913-11:14:11.txt"
I have the following Dim on top:
Dim OldName, NewName As String
What am I overlooking? Why is this kicking my kester?
Thanks for any help
Mark
Code:
Sub Move_Rename_One_File()
'You can change the path and file name
Name "C:\Users\Ron\SourceFolder\Test.xls" As "C:\Users\Ron\DestFolder\TestNew.xls"
End Sub
Now I'm the trying the FileCopy and using Ron's example of
Code:
Sub Copy_One_File()
FileCopy "C:\Users\Ron\SourceFolder\Test.xls", "C:\Users\Ron\DestFolder\Test.xls"
End Sub
I came up with the following for my code
Code:
NewName = HoldingPath & DateXTime & ".txt"
OldName = ImportPath & "Testing.txt"
MsgBox (OldName & vbCr & vbCr & NewName)
FileCopy OldName, NewName
The MsgBox shows - (under type in the Watch box is "Variant/string" for OldName and "String" for NewName. )
OldName = "\\{servername}\pad\Coding\IPR Deficiency\Chart Deficiency information\Data Files\Testing.txt"
NewName = "\\{servername}\pad\Coding\IPR Deficiency\Chart Deficiency information\Data Files\Old Import Files\20180913-11:14:11.txt"
I have the following Dim on top:
Dim OldName, NewName As String
What am I overlooking? Why is this kicking my kester?
Thanks for any help
Mark