Load DVB and run VBA macro using AutoCAD COM API in ObjectARX

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);       }     }

Comments

2 responses to “Load DVB and run VBA macro using AutoCAD COM API in ObjectARX”

  1. Suom Sarou Avatar
    Suom Sarou

    I don’t know how to load file dvb in autocad

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading