Bonjour,

Je voudrais installer une barre de progression pendant qu'un code VBA met en place un UserForm nommé "PlotForm". Ma barre de progression fonctionne bien à part mais lorsque je l'insère dans le UserForm_Initialize, cela m'affiche une erreur à la ligne "PlotForm.Show"... Voici le code ci-dessous:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub UserForm_Initialize()
 
    Dim Feuille As Worksheet
    Dim Cell As Range
    Dim k As Integer
    Dim WS_Count As Integer
    Dim ProgressIndicator As ProgressForm
    Dim n As Long
 
    WS_Count = ActiveWorkbook.Worksheets.Count
 
For k = 1 To WS_Count
 
    ActiveWorkbook.Worksheets(k).Activate
 
    Set ProgressIndicator = New ProgressForm
    ProgressIndicator.Show vbModeless
 
'Updates progress bar
    If Sheets(k).ChartObjects.Count = 0 Then
 
    If TypeName(ActiveSheet) <> "Worksheet" Then
        Unload ProgressIndicator
        Exit Sub
    End If
 
            k = k + 1
            n = k / WS_Count
            Call UpdateProgress(n)
 
    'Creates List of choice for abscissa axis and ordinate axis
        For Each Cell In Range("A1:BZA100")
                     If Application.IsText(Cell) Then
                             PlotForm.xChoice.AddItem Cell.Value
                             PlotForm.yChoice.AddItem Cell.Value
                     End If
        Next Cell
 
    End If
Next k
 
        Unload ProgressIndicator
        Set ProgressIndicator = Nothing
 
End Sub
Où UpdateProgress est la fonction suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
Sub UpdateProgress(pct)
    With ProgressIndicator
        .FrameProgress.Caption = Format(pct, "0%")
        .LabelProgress.Width = pct * 200
    End With
    DoEvents
End Sub
Je ne sais pas si ce que je souhaite faire est possible, et où, le cas échéant, je suis censé mettre la partie du code de la Progress Bar...
Merci d'avance pour votre aide...