Skip to content

Instantly share code, notes, and snippets.

@neremin
Forked from kumatti1/Module1.bas
Created June 12, 2017 20:41
Show Gist options
  • Save neremin/42088e68ed98b07b512af6c58e2f09b9 to your computer and use it in GitHub Desktop.
Save neremin/42088e68ed98b07b512af6c58e2f09b9 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