Insérer une image en pied de page avec un check box
Bonjour, j'ai un check box qui doit insérer une image dans les pieds de page de mes feuilles Excel 2010. Mais, certaines pages n'ont pas d'images, d'autres l'ont toujours même si le Check Box est inactif. Je tourne en rond sur ce débogage, est-ce que quelqu'un pourrais m'aider ?
PRÉCISION: au départ certaines feuilles ne devaient pas avoir l'image en pied de page, mais ce n'est plus une exigence, tout de même voici l'organisation des feuilles :
DATA / puis 4 feuilles qui se répètent 26 fois.
Ex.: DATA | Commande-A | Liste-A | 4x6 M-A | 4x6 A-A | Commande-B | Liste-B | 4x6 M-B | 4x6 A-B | Commande-C... ainsi de suite jusqu'à Z.
Voici le code du Check Box puis à la fin le code de l'image qui est dans la même feuille soit DATA.
-------------------------------------------------------------------------------
Code:
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
| Private Sub CheckBox1_Click()
Dim strPath As String
Dim nTotSheets As Integer
Dim n As Integer
Dim nComm As Integer
nTotSheets = ThisWorkbook.Sheets.Count
n = Int((nTotSheets - 2) / 4)
strPath = "C:\testfooter.jpg"
SavePicture Worksheets(1).Image1.Picture, strPath
For m = 1 To n
nComm = 4 * (m - 1) + 3
If Worksheets(1).Range("G7") = True Then
strPath = "C:\testfooter.jpg"
Else
strPath = ""
End If
With Worksheets(nComm).PageSetup
.RightFooterPicture.Filename = strPath
.RightFooter = "&G "
.LeftFooter = ""
End With
Next m
If Len(strPath) > 0 Then
Kill strPath
End If
nTotSheets = 0
nComm = 0
End Sub |
-----------------------------------------------------------------------------------
Code:
1 2 3
| Private Sub Image1_Click()
End Sub |
------------------------------------------------------------------------------------
MERCI D'AVANCE