Erreur 438 propriété ou méthode non gérée par cet objet

Bonjour le forum

je demande votre assistance sur une macro qui me renvoie une erreur 438. Le débobage indique que l'erreur provient de cette ligne de la macro

Sheets(SheetArray()).Unprotect 123

ci-dessous la macro complète

Private Sub CmdExportPDF_Click()
   Dim Chemin$, Fiche$, NomFiche$
   Dim SheetArray() As Variant
   Dim I&, Indx&
   Chemin = ThisWorkbook.Path & Application.PathSeparator
   Fiche = "TestV2"
   Indx = 0
   For I = 0 To LbFeuilles.ListCount - 1
      If LbFeuilles.Selected(I) Then
         ReDim Preserve SheetArray(Indx)
         SheetArray(Indx) = LbFeuilles.List(I)
         Indx = Indx + 1
      End If
   Next I

   If Indx > 0 Then
      Application.ScreenUpdating = False
      Sheets(SheetArray()).Select
      Sheets(SheetArray()).Unprotect "momo"
      NomFiche = Chemin & Fiche
      ActiveSheet.PageSetup.Orientation = xlLandscape
      ActiveSheet.PageSetup.Zoom = False
      ActiveSheet.PageSetup.FitToPagesTall = 1
      ActiveSheet.PageSetup.FitToPagesWide = 1
      ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
                                      Filename:=NomFiche, _
                                      Quality:=xlQualityMinimum, _
                                      IncludeDocProperties:=True, _
                                      IgnorePrintAreas:=False, _
                                      OpenAfterPublish:=False
      Sheets(SheetArray()).Protect "momo"
   End If
   Erase SheetArray

   Feuil1.Select
   Unload Me
   Application.GoTo [A1], True
End Sub

Bonjour,

.protect et .unprotect ne peuvent pas s'appliquer sur plus d'une feuille à la fois.

tu dois faire une boucle.

une idée de comment faire?

bonsoir,

je navigue à vue et il fait assez sombre.

sur base de ce que j'ai compris (non testé)

Private Sub CmdExportPDF_Click()
    Dim Chemin$, Fiche$, NomFiche$
    Dim SheetArray() As Variant
    Dim I&, Indx&
    Chemin = ThisWorkbook.Path & Application.PathSeparator
    Fiche = "TestV2"
    Indx = 0
    For I = 0 To LbFeuilles.ListCount - 1
        If LbFeuilles.Selected(I) Then
            ReDim Preserve SheetArray(Indx)
            SheetArray(Indx) = LbFeuilles.List(I)
            Indx = Indx + 1
            Sheets(LbFeuilles.List(I)).Unprotect "momo"
        End If
    Next I

    If Indx > 0 Then
        Application.ScreenUpdating = False
        Sheets(SheetArray()).Select
        NomFiche = Chemin & Fiche
        ActiveSheet.PageSetup.Orientation = xlLandscape
        ActiveSheet.PageSetup.Zoom = False
        ActiveSheet.PageSetup.FitToPagesTall = 1
        ActiveSheet.PageSetup.FitToPagesWide = 1
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
                                        Filename:=NomFiche, _
                                        Quality:=xlQualityMinimum, _
                                        IncludeDocProperties:=True, _
                                        IgnorePrintAreas:=False, _
                                        OpenAfterPublish:=False
        For I = 0 To LbFeuilles.ListCount - 1
            If LbFeuilles.Selected(I) Then
                Sheets(LbFeuilles.List(I)).Unprotect "momo"
            End If
        Next I
    End If
    Erase SheetArray

    Feuil1.Select
    Unload Me
    Application.GoTo [A1], True
End Sub

je navigue à vue et il fait assez sombre.

Oh sorry. Je mets le fichier en PJ.

J'essaie la solution et je vous dis.

Par contre la dernière ligne c'est pas plutot Sheets(LbFeuilles.List(I)).Protect "momo" pour protégger à nouveau les feuilles

Merci bcp pour l'aide

5testv2.zip (27.57 Ko)

Par contre la dernière ligne c'est pas plutot Sheets(LbFeuilles.List(I)).Protect "momo" pour protégger à nouveau les feuilles

Tout à fait ! tu as entièrement raison

Rechercher des sujets similaires à "erreur 438 propriete methode geree cet objet"