I am very new to VSTO addon development and C# also. I'm having the below code.
using Microsoft.Office.Tools.Ribbon;
using System;
using System.Diagnostics;
namespace POC_Powerpoint
{
public partial class Ribbon1
{
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Debug.WriteLine("POC Running");
AddCustomXmlPartToPresentation()
}
private void AddCustomXmlPartToPresentation(PowerPoint.Presentation presentation)
{
string xmlString =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
"<employee>" +
"<name>Karina Leal</name>" +
"<hireDate>1999-04-01</hireDate>" +
"<title>Manager</title>" +
"</employee>" +
"</employees>";
Office.CustomXMLPart employeeXMLPart =
presentation.CustomXMLParts.Add(xmlString, missing);
}
}
}
Once click the button_1 I want to add some custom xml into presentation. And I don't know how to run this code and how to get the Powerpoint and Office class parts.
I taken those code from ms-office docs. Can anyone help me with this? How can I insert the custom XML into the powerpoint file.