Gruppe
Dialog
Problem
Auf UserForm-Schaltflächendruck soll der Focus auf die Tabelle gesetzt werden. Nur ab XL9, da die Modal-Eigenschaft erst ab dieser Version eingestellt werden kann.
StandardModule: Modul1
Sub DialogAufruf()
frmFocus.Show
End Sub
ClassModule: frmFocus
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow _
Lib "user32" (ByVal hwnd As Long) As Long
Private m_hWndXl As Long
Private Sub cmdFocus_Click()
SetForegroundWindow m_hWndXl
ActiveCell.Select
End Sub
Private Sub UserForm_Initialize()
Application.Caption = "My Unique Caption"
m_hWndXl = FindWindow("XLMAIN", Application.Caption)
Application.Caption = Empty
End Sub