AW: Userform immer in Tabelle
11.03.2021 07:28:04
Nepumuk
Hallo,
dein 1. verstehe ich nicht. Soll das UserForm nur in einer Tabelle sichtbar sein?
Lass dir das UserForm im VBA-Editor anzeigen. Unten links im Eigenschaftsfenster setzt du die Eigenschaft "ShowModal" auf False. Damit hast du Zugriff auf die Hyperlinks und die Tabellenreiter.
Die Titelleiste löschen geht so. Im Modul des UserForms:
Option Explicit
#If Win64 Then
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongPtrA" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongPtrA" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long, _
ByVal dwNewLong As LongPtr) As LongPtr
#Else
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long, _
ByVal dwNewLong As LongPtr) As LongPtr
#End If
Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function DrawMenuBar Lib "user32.dll" ( _
ByVal hwnd As LongPtr) As Long
Private Declare PtrSafe Function SendMessageA Lib "user32.dll" ( _
ByVal hwnd As LongPtr, _
ByVal wMsg As Long, _
ByVal wParam As LongPtr, _
ByRef lParam As Any) As LongPtr
Private Declare PtrSafe Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare PtrSafe Function IsThemeActive Lib "uxtheme.dll" () As Long
Private Const GC_CLASSNAMEMSFORM As String = "ThunderDFrame"
Private Const GWL_STYLE As Long = -16&
Private Const WS_CAPTION As LongPtr = &HC00000
Private Const HTCAPTION As LongPtr = 2&
Private Const WM_NCLBUTTONDOWN As Long = &HA1
Private mlngptrHwnd As LongPtr
Private Sub UserForm_Activate()
Dim lngptrStyle As LongPtr
mlngptrHwnd = FindWindowA(GC_CLASSNAMEMSFORM, Caption)
lngptrStyle = GetWindowLongPtr(mlngptrHwnd, GWL_STYLE)
lngptrStyle = lngptrStyle And Not WS_CAPTION
Call SetWindowLongPtr(mlngptrHwnd, GWL_STYLE, lngptrStyle)
Call DrawMenuBar(mlngptrHwnd)
If IsThemeActive = 1 Then
Height = Height - 16
Else
Height = Height - 14
End If
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
Call ReleaseCapture
Call SendMessageA(mlngptrHwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub
Gruß
Nepumuk