Un esempio molto valido l'ha postato xegallo (Moderatore) qualche giorno fà, che qui riporto dopo averlo ringraziato:
codice:
Option Explicit
Dim FSO As FileSystemObject
Dim f As File
Dim dSorg As Folder
'-----------------------
Private Sub Form_Load()
ProgressBar1.min = 0
ProgressBar1.max = 100
Set FSO = New FileSystemObject
End Sub
'-----------------------
Private Sub Command1_Click()
Dim dirLenght As Long
Dim fileLenght As Long
Dim bytesscritti As Long
Set dSorg = FSO.GetFolder("D:\DATI1")
dirLenght = dSorg.Size
For Each f In dSorg.Files
fileLenght = f.Size
f.Copy "D:\"
ProgressBar1.value = Percent(0, dirLenght, bytesscritti + fileLenght)
bytesscritti = bytesscritti + fileLenght
ProgressBar1.Refresh
Next f
End Sub
'--------------------------
Function Percent(min As Long, max As Long, value As Long) As Long
'100 : x = dirlenght : bytes
Percent = value * 100 \ max
End Function
PS. ricorda di attivare il riferimento a Microsoft Scripting Runtime.