Microsoft 365 Problème de connexion entre 64 bits et 32 bits

dubarre

XLDnaute Occasionnel
Bonjour à tous,

Je viens vers vous car @patricktoulon m'avais transmis cette partie du code pour que le classeur soit compatible entre 32 bits et 64 bits hors il se passe un problème quand j'essaie de de l'ouvrir sur du 64 bits ça ne fonctionne pas, la partie ci-dessous en rouge ne veut pas fonctionner.

je voudrais pouvoir que cela fonctionne sur du 32 et 64 s'il vous plaît. Car je fais la programmation sur du 64 mais les personnes qui vont utiliser on du 32

les donnees sont fictiv

dans le module 5

Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" _
(ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private hHook As Long


VB:
Option Explicit
'Code geschrieben von Daniel Klann
#If vb7 Then
Private Declare PtrSafe Function CallNextHookEx Lib "user32" (ByVal hHook As LongLong, ByVal ncode As LongLong, ByVal wParam As LongLong, lParam As Any) As LongLong
Private Declare PtrSafe Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongLong
Private Declare PtrSafe Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As LongLong, ByVal lpfn As LongLong, ByVal hmod As LongLong, ByVal dwThreadId As LongLong) As LongLong
Private Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As LongLong) As LongLong
Private Declare PtrSafe Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (ByVal hDlg As LongLong, ByVal nIDDlgItem As LongLong, ByVal wMsg As LongLong, ByVal wParam As LongLong, ByVal lParam As LongLong) As LongLong
Private Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As LongLong, ByVal lpClassName As String, ByVal nMaxCount As LongLong) As LongLong
Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As LongLong
Public Function NewProc(ByVal lngCode As LongLong, ByVal wParam As LongLong, ByVal lParam As LongLong) As LongLong
Private hHook As LongLong
#Else
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" _
(ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private hHook As Long
#End If
Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HC_ACTION = 0
Dim RetVal
Public Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim strClassName As String, lngBuffer As LongLong
If lngCode < HC_ACTION Then
    NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
    Exit Function
End If
strClassName = String$(256, " ")
lngBuffer = 255
If lngCode = HCBT_ACTIVATE Then
    RetVal = GetClassName(wParam, strClassName, lngBuffer)
        If Left$(strClassName, RetVal) = "#32770" Then
        SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
        End If
End If
CallNextHookEx hHook, lngCode, wParam, lParam
End Function

Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, _
Optional YPos, Optional HelpFile, Optional Context) As String
Dim lngModHwnd As LongLong, lngThreadID As LongLong
lngThreadID = GetCurrentThreadId
lngModHwnd = GetModuleHandle(vbNullString)
hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
InputBoxDK = InputBox(Prompt, Title, Default, XPos, YPos, HelpFile, Context)
UnhookWindowsHookEx hHook
End Function

Sub MdpEntrer()

Dim Mdp As String

'Mdp = InputBoxDK("Entrer le mot de passe", "Demande")
'
'If Mdp <> "Apbp67120" Then
'MsgBox "Le mot de passe est incorrect", vbCritical
'Exit Sub
'ElseIf Mdp = "Apbp67120" Then

            Feuil1.Visible = True
            Feuil1.Activate
            Feuil2.Visible = xlSheetHidden
            Feuil3.Visible = xlSheetHidden
            Feuil5.Visible = xlSheetHidden
            Feuil6.Visible = xlSheetHidden
            Feuil8.Visible = xlSheetVeryHidden

        Feuil1.Range("A1:X52").Select
        ActiveWindow.Zoom = True
       Cells(1, 1).Select

'End If




End Sub

Sub MdpConsulter()

        Feuil5.Visible = True
        Feuil3.Visible = True
        Feuil5.Activate
        Feuil1.Visible = xlVeryHidden
        Feuil2.Visible = xlVeryHidden
      
With Feuil5.Cells
    .EntireColumn.Hidden = False
    .EntireRow.Hidden = False
    .Clear
    .Interior.ColorIndex = xlNone
    '.HorizontalAlignment = xlCenter
    '.VerticalAlignment = xlCenter
    '.ColumnWidth = 15
    '.RowHeight = 15
End With


      
Feuil5.Cells.Clear
ThisWorkbook.Sheets("BDD").Range("A1").CurrentRegion.Copy Sheets("Vue_listes_artistes").Range("A1")

    'Rows("1:2").Select
    'Range("A2").Activate
    'Selection.EntireRow.Hidden = True
UserForm9.Show

Range("A1").Select
    Selection.AutoFilter

End Sub

pouvez-vous m'aider à trouver la solution car cette partie de programmation je ne me suis pas encore totalement penché et je n'arrive pas trop avoir comment cela fonctionne s'il vous plaît
 

Pièces jointes

  • Gestion_des_Artistes_v00.1.32bits.xlsm
    793.2 KB · Affichages: 10
Solution

dysorthographie

XLDnaute Accro
bonjour ,
ce que t'a fourni Patrick est déjà compatible 32 bits!

il n'y a rien à comprendre avec les API juste,et c'est pas facile, trouver la quelle utiliser et comme la déclarer {Private Declare Function }

on utiliser des directive de compilation pour distinguer 32/64
#If vb7 Then '64
Private Declare PtrSafe Function CallNextHookEx
#else '32
Private Declare Function CallNextHookEx
#end IF

et invariablement dans le code
NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)

Notes que ce qui est en rouge c'est la partie 32 Bit elle sera toujours en rouge dans une version 64bits alors que ce sera l'autre partie qui sera rouge dans la version 32!

Tu auras toujours une erreur lors de l'écriture du code car tu n'es pas dans la bonne version !

En revanche si tu acquites le message d'erreur tu n'auras plus de problème par la suite.
 
Dernière édition:

dubarre

XLDnaute Occasionnel
Bonjour à toi,

Je te remercie de te pencher sur mon problème je comprends à peu près ce que tu veux dire par contre qu'est-ce que tu veux dire par

"si tu acquitte le message d'erreur tu n'auras plus problème par la suite "

ça veut dire quoi s'il te plaît
 

dubarre

XLDnaute Occasionnel
Je comprends ce que tu veux dire mais je te mets un capture d'écran et le dossier concerné pour que tu puisses voir directement ce qui pose problème en te remerciant d'avance
 

Pièces jointes

  • Capture.JPG
    Capture.JPG
    214.2 KB · Affichages: 43
  • Gestion_des_Artistes_v00.1.32bits.xlsm
    787.6 KB · Affichages: 4

Phil69970

XLDnaute Barbatruc

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 913
Membres
101 837
dernier inscrit
Ugo