Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


FSO not a collection?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,630
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> FSO not a collection?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 FSO not a collection? - 6/7/2002 7:53:46 AM   
  tinyang

 

Posts: 3
Score: 0
Joined: 6/7/2002
From: USA
Status: offline
Hello All!
I have run into some difficulty getting a file collection to be
recognized as a collection in a script. In my logfile, I keep getting a
"An error occured while processing. 451, Object not a collection.
Stopped on error. 451, Object not a collection" error, but I don't
understand why. See procedure code below. This one is really eating me up! I'm kinda new at scripting. I already have posted on a few forums, and noone seems to see what's causing the problem. Any input would be greatly
appreciated.

Set objFS = WScript.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strDestOrig)
' Set pointer to files in the folder
Set objFiles = objFolder.Files

On error resume next

For each objFile in objFiles 'this is where I get the error.
nTotalFile = nTotalFile + 1
strOldFile = mid(objFile.Path, len(strSrcOrig) + 1)
strNewFile = strDestOrig & strOldFile
If objFS.FileExists(strNewFile) Then
' File exists on target. Check dates
Set objDestFile = objFS.GetFile(strNewFile)
If objFile.DateLastModified > objDestFile.DateLastModified Then
' Source is newer
nFilesCopied = nFilesCopied + 1
' Turn off Readonly attr
If objDestFile.Attributes and 1 Then
objDestFile.Attributes = objDestFile.Attributes - 1
End if
' Turn of Hidden attr
If objDestFile.Attributes and 2 Then
objDestFile.Attributes = objDestFile.Attributes - 2
End if
' Turn of System attr
If objDestFile.Attributes and 4 Then
objDestFile.Attributes = objDestFile.Attributes - 4
End if
objLogFile.WriteLine("Updated -> " & objFile.Path & " " &
objFile.DateLastModified)
objFS.CopyFile objFile.Path, objDestFile.Path, True
Else
'Destination is not older
objLogFile.WriteLine("Skipped -> " & objFile.Path & " " &
objFile.DateLastModified)
End If
Else
'Doesn't exist on target
objLogFile.WriteLine("Added -> " & objFile.Path & " " &
objFile.DateLastModified)
nFilesCopied = nFilesCopied + 1
objFS.CopyFile objFile.Path, strNewFile, True
End if
' Errors?
If Err then
objLogFile.WriteLine("Stopped on error. " & Err.number &
Err.Description)

objLogFile.Close
Set objLogFile = Nothing
End if
Set objFS = Nothing
End if
Next
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> FSO not a collection? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts