ich habe eine recht umfangreiche Datei, welche bei mir, Excel 365 32 bit, läuft aber nicht bei anderen welche 64 bit nutzen. Wo liegt der Unterschied zwischen den Versionen? Wie kann ich jetzt diese Fehler ausmerzen? Hat einer von euch VBA programmierenden, eine 64 bit Version?
Gruß Marcus
Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen. Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
entschuldige, wenn ich nicht so schlau bin, wie ihr es seit. Heißt das, dass ich alle Public in Declare umwandeln muss?
Code:
Public/Private Declare Sub
Der Text von Microsoft ist wiedersprüchlich. Alle 32 bit Versionen sollen auf 64 bit laufen. Aber ...
Stehe genauso schlau da wie vorher.
Aber Danke für deine Antwort.
Gruß Marcus
Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen. Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
02.03.2020, 13:49 (Dieser Beitrag wurde zuletzt bearbeitet: 02.03.2020, 13:49 von marose67.)
Hallo,
kann es sein, dass das Problem hier liegt?
' Der Code für das Entfernen des Schließkreuzes wurde von Nepumuk im Herber Forum veröffentlicht Private Const GWL_STYLE = (-16) Private Const WS_SYSMENU = &H80000
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) 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 DrawMenuBar Lib "User32" (ByVal hWnd As Long) As Long
Dieser COde bezieht sich darauf:
Private Sub UserForm_activate() Dim xl_hwnd, lStyle xl_hwnd = FindWindow(vbNullString, Me.Caption) If xl_hwnd <> 0 Then lStyle = GetWindowLong(xl_hwnd, GWL_STYLE) lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU) DrawMenuBar xl_hwnd End If End Sub
Edit:
Könnte das die Lösung sein?
Option Explicit
' Der Code für das Entfernen des Schließkreuzes wurde von Nepumuk im Herber Forum veröffentlicht Private Const GWL_STYLE = (-16) Private Const WS_SYSMENU = &H80000 #If Win64 Then Public Declare PtrSafe Function FindWindow Lib "User32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As ptrLong Public Declare PtrSafe Function SetWindowPos Lib "User32" (ByVal hwnd As Long, _ ByVal hWndInsertAfter As ptrLong, ByVal X As ptrLong, ByVal Y As ptrLong, _ ByVal cx As ptrLong, ByVal cy As ptrLong, ByVal wFlags As ptrLong) As ptrLong Declare PtrSafe Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As ptrLong) As ptrLong #Else Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) 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 DrawMenuBar Lib "User32" (ByVal hwnd As Long) As Long #End If
Liebe Grüße Marcus
Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen. Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
Entpackt, landet das Ganze dann in C:\Office 2010 Developer Resources\Documents\Office2010Win32API_PtrSafe.
Je nach Excel-Bit-Version sind die Windows API's in ihrer Deklaration unterschiedlich bzw. rufen auch manchmal unterschiedliche API's auf, wie z.B. bei GetWindowLongA. Die Bit-Version steuerst Du mit der in VBA integrierten Compiler-Konstante #Win64.
Dein Code würde wie folgt aussehen, jetzt ungetestet in Excel 64 Bit. Der Code setzt mindestens Excel 2010 voraus. Und ich würde auch empfehlen, bei der Verwendung von Windows-API Variablen korrekt zu typisieren.
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hwnd As LongPtr) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As LongPtr
#If Win64 Then
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32" _ Alias "GetWindowLongPtrA" (ByVal hwnd As LongPtr, _ ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32" _ Alias "SetWindowLongPtrA" (ByVal hwnd As LongPtr, _ ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#Else
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32" _ Alias "GetWindowLongA" (ByVal hwnd As LongPtr, _ ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32" _ Alias "SetWindowLongA" (ByVal hwnd As LongPtr, _ ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#End If
Private Sub UserForm_Activate()
Dim xl_hwnd As LongPtr Dim lStyle As Long
xl_hwnd = FindWindow(vbNullString, Me.Caption)
If xl_hwnd <> 0 Then
lStyle = GetWindowLongPtr(xl_hwnd, GWL_STYLE) lStyle = SetWindowLongPtr(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU) DrawMenuBar xl_hwnd
End If
Gruß
Microsoft Excel Expert · Microsoft Most Valuable Professional (MVP) :: 2011-2019 & 2020-2022 :: 10 Awards https://de.excel-translator.de/translator:: Online Excel-Formel-Übersetzer :: Funktionen :: Fehlerwerte :: Argumente :: Tabellenbezeichner
Folgende(r) 1 Nutzer sagt Danke an maninweb für diesen Beitrag:1 Nutzer sagt Danke an maninweb für diesen Beitrag 28 • marose67
ich habe die Datei mal verschickt. Bin auf die Antwort gespannt. Auf 32 Bit läuft die auf alle Fälle. Danke für Deine Hilfe!
Gruß Marcus
Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen. Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
#End If lag in dem Code aber doch vor! Hat noch jemand einen Tipp?
Gruß Marcus
Wissen ist Macht - es ist aber nicht schlimm nicht alles zu wissen. Man muss nicht alles wissen - man muss nur wissen wo es steht, oder wo man Hilfe bekommt.
03.03.2020, 09:47 (Dieser Beitrag wurde zuletzt bearbeitet: 03.03.2020, 09:48 von maninweb.)
Hallo Markus,
sorry - ich hatte mich beim Reinkopieren des Codes hier ins Forum leider vertan: es muss Dim lStyle As LongPtr heißen, denn LongPtr wird als Rückgabedatentyp von GetWindowLongPtr erwartet. Ich hab's jetzt auch mal in Excel 64 Bit getestet. Code in der Datei im Anhang. Müsste nun gehen.
Gruß
Microsoft Excel Expert · Microsoft Most Valuable Professional (MVP) :: 2011-2019 & 2020-2022 :: 10 Awards https://de.excel-translator.de/translator:: Online Excel-Formel-Übersetzer :: Funktionen :: Fehlerwerte :: Argumente :: Tabellenbezeichner
Folgende(r) 1 Nutzer sagt Danke an maninweb für diesen Beitrag:1 Nutzer sagt Danke an maninweb für diesen Beitrag 28 • marose67