-
Notifications
You must be signed in to change notification settings - Fork 34
CustomUI.xml (Ribbon UI) injection #55
Comments
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(); |
Perhaps this idea should be canned in favor of the method presented in PR #59 |
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 There is also a script in that folder which handles the rebuilding step. It simply repackages the 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. |
Awesome @byronwall! do you have to call it from PS? |
No, you can make the calls from anywhere. That source code file is pulled from the VBA in 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. |
The CustomUI.xml is another component of the workbook that is very well suited to being stored as a text file instead of being bundled into the workbook binary. To achieve this I can think of two different solutions:
This feature can be used to implement issue #54.
The text was updated successfully, but these errors were encountered: