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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
'///////////////////////////////////////////////////////////
'Module d'affichage de la grille plein ecran ou fentre
'Auteur: patricktoulon sur developpez.com
'Version 2.0
'date: 29/01/2019
'///////////////////////////////////////////////////////////
#If Win64 Then
#If VBA7 Then
Public Declare ptrsafe Function SwL Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare ptrsafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare ptrsafe Function DrW Lib "user32" Alias "DrawMenuBar" (ByVal hwnd As Long) As Long
#ElseIf VBA6 Then
Public Declare Function SwL Lib "user32" Alias "SetWindowLongA" (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 DrW Lib "user32" Alias "DrawMenuBar" (ByVal hwnd As Long) As Long
#End If
#Else
Public Declare Function SwL Lib "user32" Alias "SetWindowLongA" (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 DrW Lib "user32" Alias "DrawMenuBar" (ByVal hwnd As Long) As Long
#End If
Type appdim: height As Long: width As Long: left As Long: top As Long: state As Long: End Type
Dim mydim As appdim
'
Sub plein_ecran(Optional wstate As Long = xlMaximized)
no_caption
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" 'donne pas tout a fait le meme resultat que displayfullscreen
With Application
'.DisplayFullScreen = True' on ne s'en sert pas
.ScreenUpdating = False
.DisplayFormulaBar = False
.DisplayStatusBar = False
If .WindowState <> xlMaximized Then
mydim.top = .top
mydim.left = .left
mydim.height = .height
mydim.width = .width
mydim.state = xlNormal
Else
mydim.state = xlMaximized
End If
.WindowState = wstate
End With
With ActiveWindow
.DisplayHeadings = False
'.DisplayGridlines = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
End Sub
'
Sub affichage_normale()
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",true)"
normal
With Application
.ScreenUpdating = False
.DisplayFullScreen = False
.DisplayFormulaBar = True
.DisplayStatusBar = True
If mydim.state = xlNormal Then
WindowState = xlNormal
.top = mydim.top
.left = mydim.left
.height = mydim.height
.width = mydim.width
Else
.WindowState = xlMaximized
End If
End With
With ActiveWindow
.DisplayHeadings = True
.DisplayGridlines = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
Application.ScreenUpdating = True
End Sub
'
Sub no_caption() ' pour enlever la caption
Handle = FindWindowA(vbNullString, Application.Caption)
SwL Handle, -16, &H94080080: SwL Handle, -20, &H0:
DrW Handle
End Sub
'
Sub normal() 'pour remettre la caption
DrW Handle
Handle = FindWindowA(vbNullString, Application.Caption)
SwL Handle, -16, &H94CF0080
End Sub |