Hello,
I have the following module setup in Access 2003, that is supposed to rename a .pdf file and then move it to another folder. When I attempt to run this, it aborts with the message 'Run-Time error 5 ..Invalid Procedure Call or Argument'. The Debugger traces back to this line:
objFS.MoveFile strSourcePath & objF1.NAME, strDestPath
Can anyone provide any insight ? Thank you.
Function AssetCopy()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strSourcePath As String, strDestPath As String
Dim OldFName As String, NewFName As String, NDate As Date, NewFileName As String, OldPath As String
strSourcePath = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\" 'This is the drive the files are residing
strSDestPath = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\TempHold\" 'This is the drive the files are residing
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strSourcePath)
Set objFiles = objFolder.Files
'OldPath = "C:\Access2000\Scripts\PDFHold\"
OldFName = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\PDFReport.pdf"
NewFName = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\AssetReport.pdf"
'NewFileName = OldFName & NDate
Name OldFName As NewFName
For Each objF1 In objFiles
'This is the drive to copy to.
objFS.MoveFile strSourcePath & objF1.NAME, strDestPath
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function
I have the following module setup in Access 2003, that is supposed to rename a .pdf file and then move it to another folder. When I attempt to run this, it aborts with the message 'Run-Time error 5 ..Invalid Procedure Call or Argument'. The Debugger traces back to this line:
objFS.MoveFile strSourcePath & objF1.NAME, strDestPath
Can anyone provide any insight ? Thank you.
Function AssetCopy()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strSourcePath As String, strDestPath As String
Dim OldFName As String, NewFName As String, NDate As Date, NewFileName As String, OldPath As String
strSourcePath = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\" 'This is the drive the files are residing
strSDestPath = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\TempHold\" 'This is the drive the files are residing
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strSourcePath)
Set objFiles = objFolder.Files
'OldPath = "C:\Access2000\Scripts\PDFHold\"
OldFName = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\PDFReport.pdf"
NewFName = "D:\CGI CTI\Asset Management\CGI Inventory\Monthly Reports\PDFHold\AssetReport.pdf"
'NewFileName = OldFName & NDate
Name OldFName As NewFName
For Each objF1 In objFiles
'This is the drive to copy to.
objFS.MoveFile strSourcePath & objF1.NAME, strDestPath
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function