Configure PowerPoint Compare & Merge in git
Asked Answered
A

1

1

PowerPoint has a feature to compare 2 PowerPoint files in the UI. It's in the Review ribbon and then Compare.

I'd like to configure git to be able to compare & merge 2 PowerPoint files from the commandline, pop open PowerPoint, resolve the changes and save.

But unfortunately I can't seem to find a way to open PowerPoint in the compare mode from without many clicks. Anyone happen to know the right way to invoke powerpnt.exe to open in this magic mode?

Adhamh answered 1/2, 2022 at 18:33 Comment(2)
Similar, but definitely not what I'm after: https://mcmap.net/q/1186990/-is-it-possible-to-diff-powerpoint-version-controlled-with-git/1445598Adhamh
Just looked up the in-program compare process and it's very UI intensive. I think you would have to find a way to do a PPT comparison by calling powerpoint.exe via the command line and triggering the compare before even attempting to go any further. Like is it possible to run something like powerpoint.exe --compare file1.ppt file2.ppt?Neoarsphenamine
A
1

After ample research, the conclusion is, while PowerPoint does support a merge mode, there is no way to open it up in that mode with a command-line parameter.

enter image description here

But the API to merge documents is available in the COM object model and thus also from .NET through the Primary Interop Assemblies.

I ended up writing a small open-source project which acts as a proxy between the command-line and PowerPoint to launch and merge files. (currently still a work in progress and rough):

https://github.com/jessehouwing/ppt-diffmerge

ppt-diffmerge-tool --local="$LOCAL" --remote="$REMOTE" --base="$BASE" --output="$RESULT" 

Core piece of code:


PowerPointApplication app = null;
Presentation presentation = null;

try
{
    app = new PowerPointApplication();
    app.PresentationCloseFinal += App_PresentationClose;

    if (!string.IsNullOrWhiteSpace(Output))
    {
        File.Copy(Local, Output, true);
        Local = Output;
    }

    presentation = app.Presentations.Open(Local);

    if (string.IsNullOrWhiteSpace(Base))
    {
        presentation.Merge(Remote);
    }
    else
    {
        presentation.MergeWithBaseline(Remote, Base);
    }

    handle.WaitOne();
}
finally
{
    Marshal.ReleaseComObject(presentation);
    Marshal.ReleaseComObject(app);
}
return 0;

And it's crazy, even supports 3-way merges!

Adhamh answered 2/2, 2022 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.