Progress bar - copying a file

yoko

Active Member
Joined
Sep 5, 2006
Messages
349
Hi,

I've got this code which copies a file from one location to another. Would it be possible to include a progress bar to show how far its complete as the file is quite large.

The code is...

Code:
Private Sub CommandButton1_Click()

If FileExists("C:\Archive.pst") Then
    cpy_email.Caption = "Copying..."
    CommandButton1.Caption = "Please wait"
    CommandButton1.Enabled = False
    CommandButton2.Enabled = False
    Application.Wait Now + TimeValue("00:00:01")
    On Error GoTo Err_FileInUse
    FileCopy "C:\Archive.pst", "M:\email\Archive.pst"
    Application.Wait Now + TimeValue("00:00:01")
    cpy_email.Caption = "Done"
    MsgBox "Done!", vbOKOnly, "Finished"
    CommandButton2.Enabled = True
    GoTo End_Sub:

Else
     MsgBox "File not found!", vbOKOnly, "Error!"
End If

Err_FileInUse:
            MsgBox "File is in use!", vbOKOnly, "Error"
            CommandButton2.Enabled = True
            CommandButton1.Enabled = True
            CommandButton1.Caption = "Backup!"
End_Sub:
End Sub

Many thanks,
 
1) Check the spelling of your paths
2) Also check you have the correct paths you need to copy FROM & TO
3) Change the name of your routine, as a matter of pratice you shouldn't name routines after inbuilt Excel routines.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,216,073
Messages
6,128,634
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top