Solved

Adding a progress bar in vbs

Posted on 2011-02-23
3
561 Views
Last Modified: 2012-05-11
I have some code that I found online which works perfectly. The code unzips a files to C:\temp. The only thing it is missing is a progress bar. The zip file is fairly big so it does take some time to extract. I wold like to ave something that the users can see it is in progress.

Thanks
'Adapted from http://www.robvanderwoude.com/vbstech_files_zip.html
 
strFile = "c:\temp\file.zip"
strDest = "c:\temp\"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If Not objFSO.FolderExists(strDest) Then
    objFSO.CreateFolder(strDest)
End If
 
UnZipFile strFile, strDest

Sub UnZipFile(strArchive, strDest)
    Set objApp = CreateObject( "Shell.Application" )
    
    Set objArchive = objApp.NameSpace(strArchive).Items()
    Set objDest = objApp.NameSpace(strDest)
 intOptions = 256
    objDest.CopyHere objArchive, intOptions
     
End Sub

Open in new window

0
Comment
Question by:clynch302
3 Comments
 
LVL 7

Expert Comment

by:shaydie
ID: 34962502
You might check this link.. sample script how to use IE to display a progress bar.

http://www.computerperformance.co.uk/ezine/ezine88.htm
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34965959
Hi there, try this.

Regards,

Rob.
Const FOF_CREATEPROGRESSDLG = &H10&

'Adapted from http://www.robvanderwoude.com/vbstech_files_zip.html
 
strFile = "c:\temp\file.zip"
strDest = "c:\temp\"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If Not objFSO.FolderExists(strDest) Then
    objFSO.CreateFolder(strDest)
End If
 
UnZipFile strFile, strDest

Sub UnZipFile(strArchive, strDest)
	Set objApp = CreateObject( "Shell.Application" )
    
	Set objArchive = objApp.NameSpace(strArchive).Items()
	Set objDest = objApp.NameSpace(strDest)
	objDest.CopyHere objArchive, FOF_CREATEPROGRESSDLG
End Sub

Open in new window

0
 

Author Closing Comment

by:clynch302
ID: 35012800
Thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now