Solved

Adding a progress bar in vbs

Posted on 2011-02-23
3
565 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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