XL 2013 Code ne fonctionne plus?

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

malinsard

XLDnaute Junior
Bonjour a tous je viens de passer sur Excel 2013 et le code d'un de mes module me renvoi une erreur, pouvez-vous m'aider?
ci-dessous le code en question:


Option Private Module

Declare Function GetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long

Declare Function SetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare Function FindWindowA Lib "User32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Sub SansX(USF As UserForm)
Dim hWnd As Long
hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", USF.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
End Sub
 
Bonjour tout le monde,

essaies ceci et tu nous dis quoi !?

Code:
Option Private Module

#If VBA7 Then
    #If Win64 Then
        Declare PtrSafe Function GetWindowLongA Lib "USER32" Alias "GetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
        Declare PtrSafe Function SetWindowLongA Lib "USER32" Alias "SetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
    #Else
        Declare PtrSafe Function GetWindowLongA Lib "USER32" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
        Declare Function SetWindowLongA Lib "USER32" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
    #End If
    Declare PtrSafe Function FindWindowA Lib "USER32" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
    Declare Function GetWindowLongA Lib "USER32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function SetWindowLongA Lib "USER32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Declare Function FindWindowA Lib "USER32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If

#If VBA7 And Win64 Then
    Dim hwnd As LongPtr
#Else
    Dim hwnd As Long
#End If

Sub SansX(USF As UserForm) 'suppr la croix userf avec: FindWindowA/SetWindowLongA/GetWindowLongA
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D") & "Frame", USF.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub


EDIT: bien que c'est beaucoup plus simple et sans problème à l'avenir de faire ceci:

'ne sort pas si Click(croix) ou AltF4
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub

'et bien entendu prévoir un bouton de sortie exemple:
Private Sub CommandButton1_Click()
Unload Me
End Sub
 
Dernière édition:
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
7
Affichages
615
Retour