We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Working with Document-Hyperlinks

Hello

I’m tying to check word, excel and powerpoint documents for dead hyperlinks.
Is there any method in Aspose.Word/Slides/Cells that allows me get and iterate all Hyperlinks from a document and replace the dead-links?

Thanks for your help and reagards
Mario

Hi Mario,

Please check the following links to update hyperlinks using Aspose.Words, Aspose.Slides and Aspose.Cells respectively.

http://www.aspose.com/docs/display/wordsnet/How+to++Replace+or+Modify+Hyperlinks
Get all the external hyperlinks in a presentation
http://www.aspose.com/docs/display/cellsnet/Editing+Hyperlinks+of+Worksheet

Best Regards,

Hello Muhammad

Thanks for your answer.
Your Solution has worked for Word and Excel, but it does not work with PowerPoint Presentations.

Here is my CodE:
foreach (var slide in presentation.Slides)
{
try
{
var hyperLinks = slide.HyperlinkQueries.GetAnyHyperlinks();

foreach (var hyperLink in hyperLinks)
{
try
{
var newHyperLink = LinkReplace.CheckHyperlink(hyperLink.HyperlinkClick.ExternalUrl);

if (newHyperLink != null)
{
hyperLink.HyperlinkManager.SetExternalHyperlinkClick(newHyperLink);
hyperLink.HyperlinkManager.SetExternalHyperlinkMouseOver(newHyperLink);
}
}
catch (Exception ex)
{
//ignore
}
}
}
catch (Exception ex)
{
//ignore
}



Here is the exception:
- $exception {“Value does not fall within the expected range.”} System.Exception {System.ArgumentException}

StackTrace " at Aspose.Slides.HyperlinkQueries.(Object , )\r\n at Aspose.Slides.HyperlinkQueries.(Object , )\r\n at Aspose.Slides.HyperlinkQueries.GetAnyHyperlinks()\r\n at CH.ZKB.LIEWG.AsposeApi.Hyperlinks.HyperlinksSlides.ReplaceHyperlinks(Presentation presentation, String oldExtension, String newExtension) in d:\Projects\CH.ZKB.LIEWG.AsposeAPI\CH.ZKB.LIEWG.AsposeAPI\Hyperlinks\HyperlinksSlides.cs:line 22" string


Regards
Mario

Hi Mario,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to request you to please try using following sample code on your end and then share your kind feedback with us. Also, I have attached the source and generated presentation for your kind reference.

Presentation pres = new Presentation(“D:\hyperlink.pptx”);<o:p></o:p>

List<String> HypLinks = new List<String>();<o:p></o:p>

//Get an Array of TextFrame objects from the first slide<o:p></o:p>

ITextFrame[] textFramesSlideOne = Aspose.Slides.Util.SlideUtil.GetAllTextBoxes(pres.Slides[0]);<o:p></o:p>

//Loop through the Array of TextFrames<o:p></o:p>

for (int i = 0; i < textFramesSlideOne.Length; i++)<o:p></o:p>

//Loop through paragraphs in current TextFrame<o:p></o:p>

foreach (Paragraph para in textFramesSlideOne[i].Paragraphs)<o:p></o:p>

//Loop through portions in the current Paragraph<o:p></o:p>

foreach (Portion port in para.Portions)<o:p></o:p>

{<o:p></o:p>

if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick != null)<o:p></o:p>

{<o:p></o:p>

HypLinks.Add(port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl);<o:p></o:p>

port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(customURL.com);<o:p></o:p>

port.Text = “customtext”;<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

pres.Save(“D:\hyperlinkURL.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);<o:p></o:p>


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

Best Regards,

Very cool, that works :wink:

Thank you Adnan

Hi Mario,


Thank you for your valuable feedback.

We are glad to know that your issue is resolved and things have started working on your end.

Please feel free to contact us if we could be of any help to you.

Best Regards,