Search code examples
c#add-invbe

VBE Add-In - How to do a "Save All"


Im writing an AddIn in C# for the VBA-Development-Environment (VBE) in ms-access. (See also here: Build add-in for VBA IDE using VB.NET ).

The VDE does not save its code moduls when starting an VBA-Program. As Im implementing a "Start Programm"-Button, I want to save all the code (Forms, Classmoduls and Modules) when starting (Similar to e.g. in Visual studio when hitting "Start debug" or build).

There is a "Saved" flag in the VBProject-class, but I cant find a "Save"-function or something similar.

But I cant find how to do this (I generally have problems finding something in the microsoft documentation - or even finding the offical microsoft class documentation for C# - but this is another point).

So: How do I save a code module?


Solution

  • Finally I did this with:

    var app = GetApp();
    app.DoCmd.RunCommand(AcCommand.acCmdCompileAndSaveAllModules);
    

    but there is also a Command

    AcCommand.acCmdSaveAllModules
    

    if you dont want to compile.

    The function GetApp is more complicated. I did this with the answer from here: How to get the correct active Application from a VBE-Add-In?