The program is blowing up at this point:

Code:
Private Sub DoCapture_Click()
Dim str_temp0 As String, i As Integer
Dim aMsg As Msg
    Open "C:\downloads\xxx.xxx" For Output As #1
    Do While i < 1000
       dummy = GetMessage(aMsg, TargetWindowHandle, 0, 0)
       str_temp0 = Str$(aMsg.hWnd) & "|"
       str_temp0 = str_temp0 & Str$(aMsg.lParam) & "|"
       str_temp0 = str_temp0 & Str$(aMsg.message) & "|"
       str_temp0 = str_temp0 & Str$(aMsg.pt) & "|"
       str_temp0 = str_temp0 & Str$(aMsg.time) & "|"
       str_temp0 = str_temp0 & Str$(aMsg.wParam) & "|"
       Print #1, str_temp0
       i = i + 1
    Loop
    Close #1

Xit_DoCapture_Click:
End Sub
Code:
Type Msg
    hWnd As Long
    message As Long
    wParam As Long
    lParam As Long
    time As Long
    pt As POINTAPI
End Type
the error message is:

Compile Error:

Only user defined-types defined in public object modules
can be coerced to or from a variant or passed to late bound
functions.
DoCapture is a command button.

TargetWindowHandle is global. I get the same message when it
is set and when it is not.

Type POINTAPI has been properly typed.

Any ideas on what kind of stupid thing I've done?