I've been stuck for a few hours on this problem :
I am developing a PowerPoint AddIn in C# and I want to use a macro from another AddIn which is a PPAM file. The PPAM file is installed and enabled.
In the Application reference I found that I need to use the Application.Run
method but I cannot get it working (nothing happens)... Here is my code:
Globals.ThisAddIn.Application.Run("PPspliT.ppam!PPspliT.PPspliT_main", null);
PPspliT.ppam
is the installed AddIn (which is located here : C:\Users\XXXX\AppData\Roaming\Microsoft\AddIns\PPspliT\
)
The module in which the PPspliT_main
macro is called is named PPspliT
.
Another thing I find strange is that Run needs to take two arguments even if the macro doesn't have any argument (that's why I put null as second argument).
I also tried to install the AddIn programmatically using this :
String addinPath = @"C:\Users\XXXXX\AppData\Roaming\Microsoft\AddIns\PPspliT";
var macroFilePath = Path.Combine(addinPath, "PPspliT.ppam");
var addins = Globals.ThisAddIn.Application.AddIns.Add(macroFilePath);
if (!(addins.Registered == MsoTriState.msoTrue && addins.Loaded == MsoTriState.msoTrue))
{
addins.Registered = MsoTriState.msoTrue;
addins.Loaded = MsoTriState.msoTrue;
}
var app = Globals.ThisAddIn.Application;
string macroToInvoke = string.Format("{0}!{1}", "PPspliT.ppam", "PPspliT.PPspliT_main");
Globals.ThisAddIn.Application.Run(macroToInvoke, null);
Thanks for your help! Acacio