質問です。(WinXP,Excel2003)
マルチスレッドで処理をしたいのですがうまくいきません。
以下のテストコード(スレッド系関数の宣言は省略)で、セルへの書き込み自体は問題なく出来るのですが、
エクセル終了時や保存時等ににエクセル自体が落ちてしまいます。
どこが問題なのでしょうか?ご教示お願いします。

'----モジュール------
Public Const STILL_ACTIVE As Long = 259
Public Function testThread(ByVal n As Long) As Long
  Dim i
  For i = 1 To 10
    Sheet1.Cells(1, n) = i
    DoEvents
  Next i
  testThread = 0
End Function
'----シート------
Private Sub test_Click()
  Dim hThd, idThd, dwExCode As Long
  hThd = CreateThread(0&, 0&, AddressOf testThread, 1, 0&, idThd)
  Do
    DoEvents
    If (GetExitCodeThread(hThd, dwExCode)) Then
      If (dwExCode <> STILL_ACTIVE) Then Exit Do
    End If
  Loop While True
  CloseHandle hThd
End Sub