Option Explicit
'#If Win64 Then ' (Office 64bit ET Win 64Bit)
' Private Declare PtrSafe Function SetWindowLongPtrA Lib "user32" (ByVal hwnd As LongLong, ByVal nIndex As Long, ByVal dwNewLong As LongLong) As LongLong
' Private Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongLong
' Private Declare PtrSafe Function GetWindowLongA Lib "user32" (ByVal hwnd As LongLong, ByVal nIndex As LongLong) As LongLong
' Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongLong, ByVal nCmdShow As LongLong) As LongLong
' #Else ' (Office 32bit ET Win 32Bit) OU (Office 32Bit ET Win 64Bit)
' Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
' Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
' Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
' #End If
#If Win64 Then ' (Office 64bit ET Win 64Bit)
Public Declare PtrSafe Function SetWindowLongPtrA Lib "user32" (ByVal hwnd As LongLong, ByVal nIndex As Long, ByVal dwNewLong As LongLong) As LongLong
Public Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongLong
Public Declare PtrSafe Function GetWindowLongA Lib "user32" (ByVal hwnd As LongLong, ByVal nIndex As LongLong) As LongLong
Public Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongLong, ByVal nCmdShow As LongLong) As LongLong
#Else ' (Office 32bit ET Win 32Bit) OU (Office 32Bit ET Win 64Bit)
Public Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
#End If
Sub Excel_Plein_Ecran()
'plein ecran
Dim hwnd As Long
'masquer les boutons
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
'plein écran
Application.DisplayFullScreen = True
'Masquer le quadrillage
ActiveWindow.DisplayGridlines = False
' Masquer les en-têtes
ActiveWindow.DisplayHeadings = False
' Masquer les barres de défilement
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
' Masquer les onglets de classeur
ActiveWindow.DisplayWorkbookTabs = False
End Sub
'rétablir
Sub Excel_Ecran_Normal()
Dim hwnd As Long
'rétablir les boutons
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
'rétablir plein écran
Application.DisplayFullScreen = False
'rétablir le quadrillage
ActiveWindow.DisplayGridlines = True
' rétablir les en-têtes
ActiveWindow.DisplayHeadings = True
' rétablir les barres de défilement
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayVerticalScrollBar = True
' rétablir les onglets de classeur
ActiveWindow.DisplayWorkbookTabs = True
End Sub