• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

VBA 32 bit & 64 bit

Status
Niet open voor verdere reacties.

Blizter

Gebruiker
Lid geworden
4 nov 2011
Berichten
71
Hoi kenners.

Ik heb een VBA gekregen van een kenner (bedankt hiervoor)
Nu werkte ik eerst op een 32 bit systeem.

Nu ben ik overgestapt op een 64 bit systeem waardoor sommige vba's niet meer werken.

Kan iemand mij helpen om ervoor te zorgen dat deze weer werkt op een 64 bit systeem en 32 bit systeem.

Alvast bedankt.

Code:
 'Constants to be used in our API functions
Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HC_ACTION = 0
 
Private hHook As Long
 
Public Function NewProc(ByVal lngCode As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long
     
    Dim RetVal
    Dim strClassName As String, lngBuffer As Long
     
    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 'A window has been activated
        RetVal = GetClassName(wParam, strClassName, lngBuffer)
        If Left$(strClassName, RetVal) = "#32770" Then 'Class  name of the Inputbox
             'This  changes the edit control so that it display the password character *.
             'You can change the Asc("*") as you please.
            SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("**"), &H0
        End If
    End If
     
     'This line will ensure that any other hooks that may be in place are
     'called correctly.
    CallNextHookEx hHook, lngCode, wParam, lParam
     
End Function
 
 '// Make it public = avail to ALL Modules
 '// Lets  simulate the VBA Input Function
Public Function InputBoxDK(Prompt As String, Optional Title As String, _
    Optional Default As String, _
    Optional Xpos As Long, _
    Optional Ypos As Long, _
    Optional Helpfile As String, _
    Optional Context As Long) As String
     
    Dim lngModHwnd As Long, lngThreadID As Long
     
     '// Lets handle any  Errors JIC! due to HookProc> App hang!
    On Error GoTo ExitProperly
    lngThreadID = GetCurrentThreadId
    lngModHwnd = GetModuleHandle(vbNullString)
     
    hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
    If Xpos Then
        InputBoxDK = InputBox(Prompt, Title, Default, Xpos, Ypos, Helpfile, Context)
    Else
        InputBoxDK = InputBox(Prompt, Title, Default, , , Helpfile, Context)
    End If
     
ExitProperly:
    UnhookWindowsHookEx hHook
     
End Function
 
Ik weet niet precies wat er mis gaat, maar volgens mij kun je zonder expliciet als administrator te draaien geen hooks zetten in 64-bit.

Ik weet ook de structuur niet van office in 64-bit mode, maar mogelijk passen de pointers ook niet in een "long". Dat is iets wat ik na zou moeten lezen (een standaard long in 32-bit is volgens mij 32bits. geen idee of een long in 64bits ook 64 bits is).
 
Blizter

In plaats van de inputbox van Daniel Klann te gebruiken, kan je net zo goed een userform gebruiken.
Veel makkelijker op te zetten en het zal zonder aanpassen ook in Office 64 bit werken.

O.a. heb je LongLong in 64 bits tov Long in 32 bits.
 
Waarom gebruikers lastig vallen met inlogschermen als je hun Excel username, windows username of netwerk computername kunt uitlezen en testen ?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan