codice:
Option Explicit
Private Declare Function GetActiveWindow Lib "user32" () 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 Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal Hwnd As Long) As Long
Private Sub Form_Activate()
    Dim Hwnd As Long
    Dim MyStr As String
    Hwnd = GetActiveWindow 'trova l'handle
    MyStr = String(GetWindowTextLength(Hwnd) + 1, Chr$(0))'crea il buffer

    GetWindowText Hwnd, MyStr, Len(MyStr)
    MsgBox MyStr
End Sub