Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid procedure call or argument

Status
Not open for further replies.

Councilk

MIS
May 14, 2003
72
0
0
US
Hello all I've been making great strides since using this forum with many technologies and want to again express my appreciation to responses to the questions.

I was able to get this script to work where it backs up the parent and sub folders. I also need to scann the source folder for files older than 30 days and delete them.

I sucessfully scripted the file deletion block of code and it works well when I run it outside of the backup bloack of code.

Please see the portion of this script in red which is giving me the "Invalid procedure call or argument"

'Option Explicit
'On error resume next

Dim objFso, objFolder, objFile, FolderPath, i, Logfile

FolderPath = "C:\"
FolderPrefix = "PPress"

sfolder = "C:\PPress\"
dFolder = "PPressBak"
Const OverWriteFiles = True

Set objFso = CreateObject("Scripting.fileSystemObject")
i = "0" & (Month(Now)) & "-" & (Year(Now))

'WScript.Echo sfolder & dFolder & i

WScript.Echo i

If objFso.FolderExists(FolderPath & dfolder & i) = False Then
Wscript.echo("Create new folder and for updating")
ObjFso.CreateFolder(FolderPath & dfolder & i)

WScript.Sleep 500

ObjFSO.CopyFolder sFolder, FolderPath & dFolder & i 'OverWriteFiles
Wscript.Echo("Ending Copy" & " " & Now)

Else

'Verify file and folder paths to move through script)

'WScript.Echo(objFolder)
Wscript.echo(folderPath & dfolder & i & " Folder Created")
Wscript.sleep 500
Wscript.echo(sfolder)
Wscript.echo(dfolder)

sFolder = "C:\PPress"
dFolder = "C:\PPressBak"

Set objFso = CreateObject("Scripting.filesystemObject")
objFSO.CopyFolder sFolder, dFolder & i, OverWriteFiles
Wscript.Echo("Ending Copy" & " " & Now)
End If

WScript.Echo("Call purging subroutine for daily cleanup")

Set logfile = objFSO.CreateTextFile(LogFilePath & "\DelFiles.Log", True)

GetFiles strFolder

Sub GetFiles(ByVal sFolder)
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(sfolder)

logfile.Write "Directory Name: " & objFolder.Path & VbCrLf
logfile.Write "Date: " & Now() & VbCrLf & VbCrLf

For Each objFile in objFolder.Files
If objfile.DateLastModified < PurgeDate Then
intFileCount = intFileCount + 1
logfile.Write "File: " & objFile.Name & vbTab & intFileCount & vbTab _
& objFile.DateLastModified & VbCrLf
logfile.Write VbCrLf

'WScript.Echo("The files listed are more than 30 days old and will be deleted" & objFile.Path)
objFSO.DeleteFile(objFile)

End If
Next
For each objFolder in objFolder.SubFolders
GetFiles objFolder.Path
Next
End Sub

 
strFolder don't seem to have any value ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PVH

I have the sFolder = "PPress\PDF" in the top portion of the script

It's the fifth statement after "Option Explicit
 
So, replace this:
GetFiles strFolder
with this !
GetFiles sFolder

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It worked after I made the change

That's it, I guess I was so frustrated I didn't realize this error existed. At the same time the error kept pointing me to 56, 1.

This item looks like an argument being fed to the subroutine named "GetFiles" is this correct to sat this is the argument the compiler was complaining about?

Thanks!
 
Anyway, I'd not comment out the Option Explicit instruction ...
 
You're right because it forces me to declare variables and makes it harder to catch mispelled items like this situation did.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top