Reputation: 30
I have a scenario where I want the user to be taken to a different slide in the same presentation when they click on a shape containing texts "take me to slide 2" from slide 1 or slide 3 using open xml.
using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, true))
{
PresentationDocument presentationPart = presentationDocument.PresentationPart;
SlideIdList slideIdList = presentationPart.Presentation.SlideIdList;
var slideParts = presentationDocument.PresentationPart.SlideParts;
SlideId firstSlideId = (SlideId)slideIdList.ChildElements[0];
foreach(var slidePart in slideParts)
{
var hyperlinkOnClicks = slidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.HyperlinkOnClick>();
string rId = "rId9999";
var newHyperLinkRelationship = slidePart.AddHyperlinkRelationship(new Uri("#" + firstSlideId.RelationshipId, Urikind.Relative), true, rId);
foreach(var hyperlinkOnClick in hyperlinkOnClicks)
{
hyperlinkOnClick.Id = newHyperLinkRelationship.Id;
}
presentation.Presentation.Save();
presentationDocument.Save();
}
}
Upvotes: 0
Views: 50