Private Declare Function GetForegroundWindow Lib "usre32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Sub Form_Load() Dim hwnd As Long, llen As Long Dim strTitle As String strTitle = Space(255) & vbNullChar hwnd = GetForegroundWindow() llen = GetWindowText(hwnd, strTitle, 255&) If llen > 0 Then strTitle = Left$(strTitle,llen) ' do what you want here based on window title Else ' error in getting window text End If End SubHTH.