Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Zip error using VBSCRIPT Error:Object not a collection

Reply
 
Old 05-26-2009   #1 (permalink)
brian


 
 

Zip error using VBSCRIPT Error:Object not a collection

The error is in this part of code below. Object not a collection. The script
still zips files but gives a msg error. I would appreciate anyone's response.


'save sfx zip archive
On Error Resume Next
FileCount = Zip.Save("")
If Err.number <> 0 Then
result = Err.description
Call LogTxt(result)
SendMail mailSubject & " - ERROR", "Error zipping file."
Else
Call LogTxt("SFX Created: " & FileCount & " Files")
End If


Here is my complete code:

Sub CreateZipSFX()
Dim Zip
Dim FileName, FileList, TempFolder, FileCount

Set Zip = CreateObject("SoftComplex.Zip")

'create new zip archive
Zip.New(zipLocation & dojFileName)

'set root folder
Zip.RootDirectory = filesLocation

Zip.SFXExtractionPathVar = appLocation

On Error Resume Next
Zip.FileList.Add("*.*")
If Err.number <> 0 Then
result = Err.description
Call LogTxt(Err.description)
SendMail mailSubject & " - ERROR", "Error zipping file."
Else
Call LogTxt("FILES ADDED TO ZIP.")
End If

'save sfx zip archive
On Error Resume Next

Set Zip = Nothing
End Sub

url:http://www.ureader.com/gp/1675-1.aspx

My System SpecsSystem Spec
Old 05-26-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Zip error using VBSCRIPT Error:Object not a collection


"brian" <keven.johnson@xxxxxx> wrote in message
news:a6f19d2919884337b2f971e7e2e6f6a9@xxxxxx
Quote:

> The error is in this part of code below. Object not a collection. The
> script
> still zips files but gives a msg error. I would appreciate anyone's
> response.
>
>
> 'save sfx zip archive
> On Error Resume Next
> FileCount = Zip.Save("")
> If Err.number <> 0 Then
> result = Err.description
> Call LogTxt(result)
> SendMail mailSubject & " - ERROR", "Error zipping file."
> Else
> Call LogTxt("SFX Created: " & FileCount & " Files")
> End If
>
>
> Here is my complete code:
>
> Sub CreateZipSFX()
> Dim Zip
> Dim FileName, FileList, TempFolder, FileCount
>
> Set Zip = CreateObject("SoftComplex.Zip")
>
> 'create new zip archive
> Zip.New(zipLocation & dojFileName)
>
> 'set root folder
> Zip.RootDirectory = filesLocation
>
> Zip.SFXExtractionPathVar = appLocation
>
> On Error Resume Next
> Zip.FileList.Add("*.*")
> If Err.number <> 0 Then
> result = Err.description
> Call LogTxt(Err.description)
> SendMail mailSubject & " - ERROR", "Error zipping file."
> Else
> Call LogTxt("FILES ADDED TO ZIP.")
> End If
>
> 'save sfx zip archive
> On Error Resume Next
>
> Set Zip = Nothing
> End Sub
>
> url:http://www.ureader.com/gp/1675-1.aspx
Your code raises many questions. I don't have "SoftComplex.zip" and don't
know what it is. Beyond that, we don't know what the following variables
refer to, or if they have values: mailSubject, appLocation, FilesLocation,
zipLocation, dojFileName. Also the subroutine LogTxt is unknown. Also, the
following variables are declared in a Dim statement but not used: FileName,
FileList, TempFolder, FileCount.

Now I also notice that the code you say raises the error does not appear in
the complete program you posted. I suspect we are not seeing the real
program. Does you error message give a line number? It would help to know
exactly which line raises the error. It might be in the Sub LogTxt that we
don't see.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 06-10-2009   #3 (permalink)
Cheeso


 
 

Re: Zip error using VBSCRIPT Error:Object not a collection

On May 26, 12:55*pm, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "brian" <keven.john...@xxxxxx> wrote in message
>
> news:a6f19d2919884337b2f971e7e2e6f6a9@xxxxxx
>
>
>
>
>
Quote:

> > The error is in this part of code below. Object not a collection. The
> > script
> > still zips files but gives a msg error. I would appreciate anyone's
> > response.
>
Quote:

> > 'save sfxziparchive
> > On Error Resume Next
> > FileCount =Zip.Save("")
> > If Err.number <> 0 Then
> > * result = Err.description
> > * Call LogTxt(result)
> > * SendMail mailSubject & " - ERROR", "Error zipping file."
> > Else
> > * Call LogTxt("SFX Created: " & FileCount & " Files")
> > End If
>
Quote:

> > Here is my complete code:
>
Quote:

> > Sub CreateZipSFX()
> > DimZip
> > Dim FileName, FileList, TempFolder, FileCount
>
Quote:

> > SetZip= CreateObject("SoftComplex.Zip")
>
Quote:

> > 'create newziparchive
> >Zip.New(zipLocation & dojFileName)
>
Quote:

> > 'set root folder
> >Zip.RootDirectory = filesLocation
>
Quote:

> >Zip.SFXExtractionPathVar = appLocation
>
Quote:

> > On Error Resume Next
> >Zip.FileList.Add("*.*")
> > If Err.number <> 0 Then
> > result = Err.description
> > Call LogTxt(Err.description)
> > SendMail mailSubject & " - ERROR", "Error zipping file."
> > Else
> > Call LogTxt("FILES ADDED TOZIP.")
> > End If
>
Quote:

> > 'save sfxziparchive
> > On Error Resume Next
>
Quote:

> > SetZip= Nothing
> > End Sub
>>
> Your code raises many questions. I don't have "SoftComplex.zip" and don't
> know what it is. Beyond that, we don't know what the following variables
> refer to, or if they have values: mailSubject, appLocation, FilesLocation,
> zipLocation, dojFileName. Also the subroutine LogTxt is unknown. Also, the
> following variables are declared in a Dim statement but not used: FileName,
> FileList, TempFolder, FileCount.
>
> Now I also notice that the code you say raises the error does not appear in
> the complete program you posted. I suspect we are not seeing the real
> program. Does you error message give a line number? It would help to know
> exactly which line raises the error. It might be in the Sub LogTxt that we
> don't see.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -

DotNetZip is a free zip library+tool; it can be used from within
VBScript.
http://dotnetzip.codeplex.com

Example code to create a zip file:
-----------------------------
dim filename
filename = "C:\temp\ZipFile-created-from-VBScript.zip"

WScript.echo("Instantiating a ZipFile object...")
dim zip
set zip = CreateObject("Ionic.Zip.ZipFile")

WScript.echo("using AES256 encryption...")
zip.Encryption = 3

WScript.echo("setting the password...")
zip.Password = "This is the Password."

WScript.echo("adding a selection of files...")
zip.AddSelectedFiles("*.js")
zip.AddSelectedFiles("*.vbs")

WScript.echo("setting the save name...")
zip.Name = filename

WScript.echo("Saving...")
zip.Save()

WScript.echo("Disposing...")
zip.Dispose()

WScript.echo("Done.")
-----------------------------

You can also create self-extracting archives. Lots of other options.
Check it out.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is it possible to use Object.Object notation in vbscript ? VB Script
Object not a collection error VB Script
Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep' VB Script
object not a collection VB Script
How to Create Collection Generic Class using new-object PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46