supprimer code à l'enregistrement

petchy

XLDnaute Occasionnel
bonsoir

dns mon classeur j'ai se code à l'ouverture
Private Sub Workbook_BeforeClose(Cancel As Boolean)
remetmenu
End Sub
Private Sub Workbook_Open()
suprimenu
End Sub

la pas de probleme sa fonctionne
et sur une feuille j'ai un bouton pour sauvegarder le classeur avec se code
Private Sub CommandButton1_Click()
remetmenu
CommandButton1.Visible = False
CommandButton2.Visible = False
CommandButton3.Visible = False
Rows("1:1").Select
Selection.Delete Shift:=xlUp

Application.Dialogs(xlDialogSaveAs).Show
Application.DisplayAlerts = False
CommandButton1.Visible = True
CommandButton2.Visible = True
CommandButton3.Visible = True
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Selection.RowHeight = 36
ActiveSheet.Shapes("CommandButton1").Select
Selection.ShapeRange.IncrementLeft -0.75
Selection.ShapeRange.IncrementTop -36.75
ActiveSheet.Shapes("CommandButton2").Select
Selection.ShapeRange.IncrementLeft -1.5
Selection.ShapeRange.IncrementTop -33.75
ActiveSheet.Shapes("CommandButton3").Select
Selection.ShapeRange.IncrementLeft 0.75
Selection.ShapeRange.IncrementTop -33#
CommandButton1.Height = 33
CommandButton2.Height = 33
CommandButton3.Height = 33
Range("A1").Select
suprimenu
'Application.Quit
End Sub
tous fonctionne bien,mais le petit soucis c'est quand j'enregistre le classeur sous un autre nom,il enregistre aussi se code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
remetmenu
End Sub
Private Sub Workbook_Open()
suprimenu
End Sub
donc quand j'ouvre le nouveau classeur je n'est plus de barre.
ma question est,comment sauvegarder mon classeur sans mettre les code si dessus
Merci
 

qoq xn3i^

XLDnaute Nouveau
Re : supprimer code à l'enregistrement

Bonsoir Petchy, le forum,

Un début peut - être :

Sur ta version d'Excel, as - tu un l'argument SaveAsUi pour before save ?

En fonction de ton action, saveasui sera vrai ou faux.

ce qui pourra donner :

Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)

If saveasui = true then ToutCodeSouhaité

Bonne nuit.
 

Discussions similaires

Statistiques des forums

Discussions
312 337
Messages
2 087 390
Membres
103 534
dernier inscrit
Kalamymustapha