chac-attack
XLDnaute Nouveau
Bonjour le forum,
j'ai une petite requète pour vous, j'ai une macro qui est un peu longuette et je souhaiterai qu'a l'ouverture ainsi qu'a la fermeture, elle prenne moins de temps. Pourriez-vous y jetter un oeil afin de la nettoyer un peu?
Dans Thisworkbook
Option Explicit
Dim mafeuil As Worksheet
Dim personneloguee As String
Dim personneutilisatrice As String
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'remet barre menu
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = True
Range("a151").Select
ActiveWindow.Zoom = False
'
With Application
.DisplayFullScreen = False
.DisplayStatusBar = True
.DisplayFormulaBar = True
End With
'
Application.ScreenUpdating = False
Sheets("menu").Activate
With Application
.CommandBars(1).Enabled = True
.DisplayFullScreen = False
End With
With ActiveWindow
.DisplayHeadings = True
.DisplayOutline = True
.DisplayWorkbookTabs = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
fermeture_fichier
ThisWorkbook.Save
End Sub
Private Sub Workbook_Open()
'enlève barre de menu
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = False
Range("a151").Select
ActiveWindow.Zoom = True
'
With Application
.DisplayFullScreen = True
.DisplayStatusBar = False
.DisplayFormulaBar = False
With .CommandBars("worksheet menu bar")
.Enabled = False
.Visible = True
End With
With .CommandBars("cell")
.Enabled = False
End With
End With
'
Application.ScreenUpdating = False
Sheets("menu").Activate
With Application
.CommandBars(1).Enabled = False
.DisplayFullScreen = True
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayOutline = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.ScreenUpdating = True
Sheets("menu (2)").Select
Sheets("menu").Select
'accès administrateur
Application.ScreenUpdating = False
personneloguee = Environ("username")
personneutilisatrice = Application.UserName
'
If personneloguee = "Administrateur" Then
For Each mafeuil In Worksheets
mafeuil.Visible = True
mafeuil.Select
ActiveSheet.Unprotect Password:="admin"
Next mafeuil
Sheets("menu").Select
Else
On Error Resume Next
Sheets("création de liste").Visible = True
Sheets("menu").Activate
Sheets("renseignements brh").Visible = False
Sheets("suivi médical recrue").Visible = False
Sheets("prêt bsp").Visible = True
Sheets("liste de section").Visible = True
End If
End Sub
Function fermeture_fichier()
For Each mafeuil In Worksheets
mafeuil.Visible = True
mafeuil.Select
ActiveSheet.Protect Password:="admin"
Next mafeuil
End Function
ensuite dans chaques feuille j'ai cette macro:
Private Sub Worksheet_Activate()
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = False
Range("a151").Select
ActiveWindow.Zoom = True
'
With Application
.DisplayFullScreen = True
.DisplayStatusBar = False
.DisplayFormulaBar = False
With .CommandBars("worksheet menu bar")
.Enabled = False
.Visible = True
End With
With .CommandBars("cell")
.Enabled = False
End With
End With
'
Application.ScreenUpdating = False
Sheets("menu (6)").Activate
With Application
.CommandBars(1).Enabled = False
.DisplayFullScreen = True
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayOutline = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.ScreenUpdating = True
End Sub
Voilà j'ai regardé différents fil mais je ne comprends pas comment remplacer les .select etc...
merci d'avance
Chac-attack
j'ai une petite requète pour vous, j'ai une macro qui est un peu longuette et je souhaiterai qu'a l'ouverture ainsi qu'a la fermeture, elle prenne moins de temps. Pourriez-vous y jetter un oeil afin de la nettoyer un peu?
Dans Thisworkbook
Option Explicit
Dim mafeuil As Worksheet
Dim personneloguee As String
Dim personneutilisatrice As String
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'remet barre menu
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = True
Range("a151").Select
ActiveWindow.Zoom = False
'
With Application
.DisplayFullScreen = False
.DisplayStatusBar = True
.DisplayFormulaBar = True
End With
'
Application.ScreenUpdating = False
Sheets("menu").Activate
With Application
.CommandBars(1).Enabled = True
.DisplayFullScreen = False
End With
With ActiveWindow
.DisplayHeadings = True
.DisplayOutline = True
.DisplayWorkbookTabs = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
fermeture_fichier
ThisWorkbook.Save
End Sub
Private Sub Workbook_Open()
'enlève barre de menu
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = False
Range("a151").Select
ActiveWindow.Zoom = True
'
With Application
.DisplayFullScreen = True
.DisplayStatusBar = False
.DisplayFormulaBar = False
With .CommandBars("worksheet menu bar")
.Enabled = False
.Visible = True
End With
With .CommandBars("cell")
.Enabled = False
End With
End With
'
Application.ScreenUpdating = False
Sheets("menu").Activate
With Application
.CommandBars(1).Enabled = False
.DisplayFullScreen = True
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayOutline = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.ScreenUpdating = True
Sheets("menu (2)").Select
Sheets("menu").Select
'accès administrateur
Application.ScreenUpdating = False
personneloguee = Environ("username")
personneutilisatrice = Application.UserName
'
If personneloguee = "Administrateur" Then
For Each mafeuil In Worksheets
mafeuil.Visible = True
mafeuil.Select
ActiveSheet.Unprotect Password:="admin"
Next mafeuil
Sheets("menu").Select
Else
On Error Resume Next
Sheets("création de liste").Visible = True
Sheets("menu").Activate
Sheets("renseignements brh").Visible = False
Sheets("suivi médical recrue").Visible = False
Sheets("prêt bsp").Visible = True
Sheets("liste de section").Visible = True
End If
End Sub
Function fermeture_fichier()
For Each mafeuil In Worksheets
mafeuil.Visible = True
mafeuil.Select
ActiveSheet.Protect Password:="admin"
Next mafeuil
End Function
ensuite dans chaques feuille j'ai cette macro:
Private Sub Worksheet_Activate()
Dim cbar As CommandBar
Dim i As Byte
'
For Each cbar In Application.CommandBars
If cbar.BuiltIn = True Then
If cbar.Enabled = False Then cbar.Enabled = True
End If
Next cbar
ActiveWindow.DisplayHeadings = False
Range("a151").Select
ActiveWindow.Zoom = True
'
With Application
.DisplayFullScreen = True
.DisplayStatusBar = False
.DisplayFormulaBar = False
With .CommandBars("worksheet menu bar")
.Enabled = False
.Visible = True
End With
With .CommandBars("cell")
.Enabled = False
End With
End With
'
Application.ScreenUpdating = False
Sheets("menu (6)").Activate
With Application
.CommandBars(1).Enabled = False
.DisplayFullScreen = True
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayOutline = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.ScreenUpdating = True
End Sub
Voilà j'ai regardé différents fil mais je ne comprends pas comment remplacer les .select etc...
merci d'avance
Chac-attack