VBA AddressOf Crash Office App

女生的网名这么多〃 提交于 2019-12-05 16:01:45

Found the solution.

Things I change:

  • CallbackMsg from function to sub
  • String Parameter filled with Data VarPtr("Hallo Welt")

RUNNING VERSION:

Private Declare Function CallWindowProc _
                          Lib "user32.dll" Alias "CallWindowProcA" ( _
                              ByVal lpPrevWndFunc As Long, _
                              ByVal hwnd As Long, _
                              ByVal msg As Long, _
                              ByVal wParam As Long, _
                              ByVal lParam As Long) As Long

private Sub CallbackTest2()
   CallWindowProc AddressOf CallbackMsg, VarPtr("Hallo Welt"), 0, 0, 0
End Sub

Private Sub CallbackMsg( _
        msg As String, _
        ByVal nUnused1 As Long, _
        ByVal nUnused2 As Long, _
        ByVal nUnused3 As Long)
    MsgBox msg
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!