Macro fonctionne qu'en pas à pas

Bonjour,

J'ai mis en place une macro qui fonctionne parfaitement bien sur Office 365, Office 2016 mais ne fonctionne qu'en pas à pas sur Office 2010, je précise la version est peut-être le problème ?

Cette macro est utilisé pour modifier l'en-tête et pied de page + une image, et que je lance la macro rien ne se passe, mais quand je fais la macro pas à pas (f8) cela fonctionne très bien je ne comprend pas d'où vient l'erreur,

Je vous joins aussi un faux fichier si cela peut aider

J'utilise beaucoup l'enregistrement de macro, alors peut-être avez de meilleures techniques pour mon code

En vous remerciant,

23test.zip (116.55 Ko)
Sub Offshore()
'
' Offshore Macro
'

'Modification de l'étiquette pour Offshore Surf

    Sheets("Etiquettes").Select
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "EXP : BOURBON OFFSHORE SURF"
    Sheets("SONASURFLAD").Select

'Modification de l'image de signature Offshore Surf

    ActiveSheet.Unprotect
Dim s As Shape
For Each s In Feuil1.Shapes
    If s.Type = msoPicture Then If s.TopLeftCell.Address(0, 0) = "B2" Then s.Delete
    Next
    Range("G33").Select
    ActiveSheet.Pictures.Insert( _
        "G:\Bourbon\FACTURES & FDS\Photo Facture\Off Sign.PNG").Select
    Selection.ShapeRange.ScaleWidth 0.900555179, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.7005550319, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.IncrementLeft -0.75
    Selection.ShapeRange.IncrementTop -24.75
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

'Modification de l'en tête et pied page pour Offshore

    ActiveSheet.PageSetup.LeftHeaderPicture.Filename = _
        "G:\Bourbon\FACTURES & FDS\Photo Facture\Off En tête.PNG"
    ActiveSheet.PageSetup.FirstPage.LeftHeader.Picture.Filename = _
        "G:\Bourbon\FACTURES & FDS\Photo Facture\Off En tête.PNG"
    ActiveSheet.PageSetup.LeftFooterPicture.Filename = _
        "G:\Bourbon\FACTURES & FDS\Photo Facture\Off Pied.PNG"
    ActiveSheet.PageSetup.FirstPage.LeftFooter.Picture.Filename = _
        "G:\Bourbon\FACTURES & FDS\Photo Facture\Off Pied.PNG"
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = "$A$1:$I$38"
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = "&G"
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = "&G"
        .CenterFooter = ""
        .RightFooter = "&KFF0000&P"
        .LeftMargin = Application.InchesToPoints(0)
        .RightMargin = Application.InchesToPoints(0)
        .TopMargin = Application.InchesToPoints(1.10236220472441)
        .BottomMargin = Application.InchesToPoints(0)
        .HeaderMargin = Application.InchesToPoints(0.511811023622047)
        .FooterMargin = Application.InchesToPoints(0)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintSheetEnd
        .CenterHorizontally = True
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 80
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = True
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = False
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = "&G"
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = "&G"
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
End Sub

Bonjour, Si le fichier fonctionne avec 365 et office 2016.

Je pense que pour un office 2010 çà ne vient pas du fichier mais il doit y avoir une option de sécurité des macros qui est cochées dans les options.

Bonjour,

Nous avons regardé et essayé juste après et tout est bien activé, on a essayé la dernière "activer toutes les macros" aussi mais rien à faire ça ne fonctionne pas

2010

Effectivement, la je vois pas trop ; sur des anciennes version parfois il fallait activer manuellement des "Macro complémentaire"

pour que certains fichier soit utilisables ; mais comme je pas à pas fonctionne j'ai un doute.

Rechercher des sujets similaires à "macro fonctionne pas"