By Fenton Webb
Issue
How can I load a .dvb and run the macro using AutoCAD COM interface?
Solution
#import "acax19ENU.tlb" no_implementation raw_interfaces_only #include #include #include using namespace AutoCAD; LoadVBARunMacro() { // setup the VBA macro DVB details CComBSTR bsrtVBAName = _T("d:\temp\Project.dvb"); // setup the macro name :pass your macro name here CComBSTR bstrMacro = _T("test"); // get acad's iDispatch IAcadApplicationPtr pAcad = acedGetIDispatch(FALSE); // now load the DVB HRESULT hr = pAcad->LoadDVB(bsrtVBAName.m_str); // if ok if (SUCCEEDED(hr)) { // run the macro hr = pAcad->RunMacro(bstrMacro.m_str); // unload the DVB if you want hr = pAcad->UnloadDVB(bsrtVBAName.m_str); } }

Leave a Reply