by Fenton Webb
Here’s how to invoke a function Public Sub Test() declared in VBA from .NET; use acedCmd() and run –vbarun
// how to call VBA from .NET #if AC2013 [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")] #else [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")] #endif private static extern int acedCmd(System.IntPtr vlist); [CommandMethod("callVBA")] public void callVBA() { ResultBuffer rb = new ResultBuffer(); // RTSTR = 5005 rb.Add(new TypedValue(5005, "_.-vbarun")); rb.Add(new TypedValue(5005, "test")); // start vbarun running 'ThisDrawing.Test() acedCmd(rb.UnmanagedObject); }

Leave a Reply to Alexander RivilisCancel reply