How to find slide number where hyperlink is?

Hi Aspose team,

is there anyway to loop through hyperlinks in Powerpoint presentation and identify on which slide hyperlink is?
I am using HyperlinkQueries.GetAnyHyperlinks to loop through collection but was not able to find way to match identified hyperlink and slide where it is.

Thx,
Oliver

Well, text is wrong. If hyperlink is on some slide behind text it is easy to find slide number.
Problem is with following scenario:

  • on slide you have image which is with hyperlink
  • to find hyperlink I am using HyperlinkQueries.GetAnyHyperlinks which is helping me find links but I cannot find slide number

Reason for this is that I have request to check all links in Powerpoint presentation and report broken links. If I cannot find where they are my end users will have issues to figure out what has to be repaired.

Thx for help

@dr_oli,

I have observed the requirements shared by you and like to share that if you want to get the slide or respective shape index on which hyperlink is set then you need to traverse all slides and every shape inside each slide to access the hyperlink. This way you will be able to get the slide index and also the shape index on which hyperlink is applied. I suggest you to please visit the below thread link for your convenience as well.

Hi Mudassir,

I am not able to access this thread. Could you please let me know why?

I am in need of the same solution.

Thanks!
Jon

@vpedada.connectpw,

I have copied the solution for your convenience below. It updates the hyperlink as well as the portion text.

Presentation pptxPresentation = new Presentation("D:\test.pptx");

List HypLinks = new List();

//Get an Array of TextFrame objects from the first slide
ITextFrame[] textFramesSlideOne = Aspose.Slides.Util.SlideUtil.GetAllTextBoxes(pptxPresentation.Slides[0]);

//Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.Length; i++)

//Loop through paragraphs in current TextFrame
foreach (Paragraph para in textFramesSlideOne[i].Paragraphs)

//Loop through portions in the current Paragraph
foreach (Portion port in para.Portions)
{
if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick != null)
{
HypLinks.Add(port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl);
port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick("customURL.com");
port.Text = "customtext";
}
}
pptxPresentation.Save(@"D:\test.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

I hope this will be helpful. Please share if I may help you further in this regard.