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

Free Support Forum - aspose.com

Modification of existing hyperlinks/OLE Object links in presentation

Hi Aspose team,

my scenario is that I need to open existing Powerpoint file and to search for existing hyperlinks and OLE Object links.

When I find link I need to replace its address (for example, I need to find all links to google and replace with oliver; www.google.com will be replaced by www.oliver.com).

I tried to find something in API but I am finding only ReadOnly properties (for example, ExternalUrl).

What is your recommendation here? Is this possible at all?

What to do in case of OLE Object links? Do you have some samples to share?

Thanks in advance,
Oliver

Hi Oliver,

I have observed your requirements and like to share that hyperlinks and Ole frames are two different subjects in presentation. In ole frame you can have embedded or linked objects. Where as in case of hyperlinks you can set internal or external hyperlinks on clicks and mouse hovers. Actually, hyperlinks are defined by HyperLinkManager class that has its instance on shape level and text portion level. The shape level means that you can set the hyper link on click or hovering over shape. Where as hyperlink on text portion level defines the internal/external hyperlink on portion of text inside any paragraph. You can use the following example to develop the concept and modify this as per your requirements in your environment.

public static void AddHyperlink2()
{
//Instantiate a Presentation class that represents a PPTX//Instantiate a Presentation class that represents a PPTX
Presentation pptxPresentation = new Presentation();

//Get first slide
ISlide slide = pptxPresentation.Slides[0];

//Add Empty Slide
pptxPresentation.Slides.AddEmptySlide(pptxPresentation.LayoutSlides[0]);

//Add an AutoShape of Rectangle Type
IAutoShape pptxAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 150, 150, 50);

ITextFrame ITextFrame = pptxAutoShape.TextFrame;

//Add some text to the frame
ITextFrame.Paragraphs[0].Portions[0].Text = “Slide Two”;

if( ITextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick!=null)
{
if(ITextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick.ExternalUrl==“google.com”)

//Setting new External URL
ITextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkManager.SetExternalHyperlinkClick("new.com");

else
//Setting new internal URL
ITextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkManager.SetInternalHyperlinkClick(pptxPresentation.Slides[0]);
//Set Hyperlink for the portion text

}

//Save the PPTX Presentation
pptxPresentation.Save(“D:\Aspose Data\hLinkPPTX.pptx”, SaveFormat.Pptx);

}

Please also visit this thread link , thread link 2 and this documentation link for more information about hyperlinks. Please visit this documentation link for further details about Ole frames. I hope the shared information will be helpful. Please share, if I may help you further in this regard.

Many Thanks,