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