Giter Club home page Giter Club logo

Comments (5)

mattpalermo avatar mattpalermo commented on August 10, 2024

As a reference, this is the code that EffOff uses to achieve CustomUI injection:

            string CustomUIContent = File.ReadAllText(config.CustomUI);

            SpreadsheetDocument document = SpreadsheetDocument.Open(opts.target, true);
            RibbonAndBackstageCustomizationsPart part = document.RibbonAndBackstageCustomizationsPart;
            if (part == null)
            {
                part = document.AddRibbonAndBackstageCustomizationsPart();
            }
            part.CustomUI = new CustomUI(CustomUIContent);
            part.CustomUI.Save();
            document.Close();

from vba-ide-code-export.

mattpalermo avatar mattpalermo commented on August 10, 2024

Perhaps this idea should be canned in favor of the method presented in PR #59

from vba-ide-code-export.

byronwall avatar byronwall commented on August 10, 2024

One way to do this: https://github.com/byronwall/bUTL/blob/master/scripts/BuildFile.bas

I've been working on an Excel utility add-in that includes a "build from source" option to help with getting source back into git. It roughly duplicates your efforts here but includes the steps to export the Ribbon definition since it's a core part of the add-in. I took the 2nd approach listed above: extract the xlam file and dump those files somewhere. I put the files into a folder called src/package which is then checked into git. The downside of keeping all the files is that they are user/workstation specific, so you get a number of extra diffs that aren't intended. I could probably only keep the CustomUI file, but I haven't pursued that. (The same thing happens with frx files which may not have actually changed).

There is also a script in that folder which handles the rebuilding step. It simply repackages the package folder, opens the add-in, deletes all the existing VBA code, and then reimports the new modules from source. It could be improved, but has worked so far.

I call the Excel macros from PowerShell to give a simple command line interface instead of having to open the add-in exporter in Excel.

from vba-ide-code-export.

spences10 avatar spences10 commented on August 10, 2024

Awesome @byronwall! do you have to call it from PS?

from vba-ide-code-export.

byronwall avatar byronwall commented on August 10, 2024

No, you can make the calls from anywhere. That source code file is pulled from the VBA in build manager.xlsm. The paths in that workbook/macro are currently relative to how the repo is setup, but those could be easily changed or made variable. Look for the spots where it says butl.xlam, temp.zip, src/..., etc. That code handles both the import and export of the source code and Excel file unzipping/repackaging.

The PowerShell part of it was to avoid opening Excel to run the macros. If you're looking to integrate this into an existing Excel add-in, obviously having to open Excel is not a concern. The PowerShell file is simply starting an instance of Excel and running the macro behind the scenes. You need Excel running somewhere to get working access to the VBE commands to export the source code. You don't need VBE/Excel to unzip the Excel file or repackage it; just to get the source code extracted.

from vba-ide-code-export.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.