Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created December 28, 2014 23:26
Show Gist options
  • Save kumatti1/ddb722323703c5e11c59 to your computer and use it in GitHub Desktop.
Save kumatti1/ddb722323703c5e11c59 to your computer and use it in GitHub Desktop.
VBA_Test
Option Explicit
Declare PtrSafe Function DispInvoke Lib "OleAut32" _
(ByVal arg1 As LongPtr, _
ByVal arg2 As LongPtr, _
ByVal arg3 As Long, _
ByVal arg4 As Integer, _
arg5 As Any, _
arg6 As Variant, _
arg7 As Any, _
arg8 As Any) As Long
Const DISPATCH_METHOD = 1
Sub hoge()
Dim rt As Variant
Dim dp(3) As LongPtr
Dim hr&
Dim ptr As LongPtr
ptr = VBA.CLngPtr(AddressOf func)
hr = DispInvoke(ptr, 0, 0, DISPATCH_METHOD, dp(0), rt, 0, 0)
Debug.Print Hex$(hr), rt
End Sub
Sub func()
MsgBox "test"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment