Code VBA fonctionnant en 32 bits mais pas en 64 bits

27code.txt (1.73 Ko)

Bonjour,

J'ai un ancien code VBA fonctionnant en 32 bits et j'aimerai le faire fonctionner sous 64 bits.

J'ai bien consulté google pour trouver la solution, mais voilà je ne suis pas à la hauteur pour comprendre toutes ces explications et puis à mon âge on est pas aussi performant que les plus jeunes.

Je vous joins le fichier code.

Pouvez-vous m'aider ?

Je vous en remercie énormément par avance.

Bonjour,

ci-dessous un exemple pour rendre compatible un code entre le 32 et 64 bits !

' ici deux déclarations de bibliothèques afin d'être compatible 32bits et 64bits
#If VBA7 Then
    Public Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Public Declare PtrSafe Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
                    ByVal Y As Long) As Long
    Public Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#Else
    Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
                    ByVal Y As Long) As Long
    Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If

le IF VBA7 détecte le 64 bits, alors les function "32" sont initialisées avec le PtrSafe

Si cela ne suffit pas il faut peut-être aussi définir les variables "Long" en "PtrLong", mais comme sur l'exemple ce n'est pas forcément utile :

Public Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As PtrLong) As Long

@ bientôt

LouReeD

Bonjour LouReeD,

Je te remercie pour ta réponse mais malheureusement je n'y comprends rien, je suis vraiment nul en programmation, tu veux dire par là que si je fais un copier coller du code que tu me donnes devant mon code celui-ci devrait fonctionner ?

Merci pour ta patience

Bonsoir,

puisqu'il vous faut un copier/coller :

#If VBA7 Then
    Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
#Else
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
#End If

Private Const GWL_STYLE As Long = (-16)  'The offset of a window's style
Private hWnd, IStyle
Public x0, y0 As Integer
Public numRow As Integer

@ bientôt

LouReeD

désolé ça ne fonctionne pas, j'obtiens un message d'erreur de compilation. Le voici.

Private Sub aide1_Click()
Dim mess As String

mess = "Pour ces 2 boutons, importez les résultats du loto ou de l'euromilion à partir du site internet, en choisissant le format excel.CSV"
mess = mess & vbLf & "Copiez la feuille du fichier téléchargé et collez-la en A1 dans la feuille 'ResultatsLoto' ou 'ResultatsEuro' selon le cas,"
mess = mess & vbLf & "puis cliquez sur l'un ou l'autre en fonction de votre étude." & vbLf
mess = mess & vbLf & "L'action mettra en forme les données dans la feuille 'loto' préparée pour cela."

MsgBox mess
End Sub

Private Sub CommandButton1_Click()
    usf_analyses.Show 0
End Sub

Private Sub CommandButton14_Click()
    usf_expliqColonnesLOTO.Show 0
End Sub

Private Sub CommandButton15_Click()
    usf_apropos.Show 1
End Sub

Private Sub CommandButton16_Click()
    usf_principe.Show 1
End Sub

Private Sub CommandButton2_Click()
    usf_importLoto.Show 0
End Sub

Private Sub CommandButton3_Click()

End Sub

Private Sub CommandButton4_Click()
    Sheets("Analyse").Select
End Sub

Private Sub CommandButton5_Click()

End Sub

Private Sub CommandButton7_Click()
    usf_analyses.Show 0
    usf_analyses.MultiPage1.Value = 0
End Sub

Private Sub CommandButton8_Click()
    usf_analyses.Show 0
    usf_analyses.MultiPage1.Value = 2
End Sub

Private Sub feuilleCombinatoireSurSaisie_Click()
    Sheets("liste1").Select
End Sub

Private Sub feuilleDuGraphique_Click()
    Sheets("graph").Select
End Sub

Private Sub feuilleHistoNum_Click()
    Sheets("HistoNum").Select
End Sub

Private Sub feuilleHistorique255075tirages_Click()
    Sheets("255075T").Select
End Sub

Private Sub feuilleListeXMLtirages_Click()
    Sheets("XML").Select
End Sub

Private Sub feuilleLoto_Click()
    Sheets("loto").Select
End Sub

Private Sub feuilleResultatsDuLoto_Click()
    Sheets("ResultatsLoto").Select
End Sub

Private Sub feuilleResultatsEuromillion_Click()
    Sheets("ResultatsEuro").Select
End Sub

Private Sub feuilleTriangleDesPaires_Click()
    Sheets("triangle").Select
End Sub

Private Sub UserForm_Initialize()
'a placer dans chaque userform pour disposer
'des 3 boutons min max supp fenetre
  MinMaxSupp Me

End Sub
Private Sub UserForm_Click()

End Sub

Sans fichier ... Hélas...

@ bientôt

LouReeD

Bonjour LouReeD

Voici le code en question.

Bonsoir,

Dîtes moi, quelle version d'Excel avez-vous ? Par que j'aimerais connaître cette version où un fichier texte suffit à faire fonctionner une macro...
Lorsque je parle de fichier c'est votre fichier Excel, merci.

Sinon je ne peux pas grand chose...

@ bientôt

LouReeD

Bonsoir,

J'utilise excel 2019.

Et le texte je le copie dans VBA.

Et moi le fichier que je vous demande c'est le .XSLM

@ bientôt

LouReeD

Rechercher des sujets similaires à "code vba fonctionnant bits pas"