I have inserted an image to powerpoint using c# and have inserted a hyperlink to the picture and its working perfectly.But now i need to read the hyperlink of that picture which i have inserted using c#.
Whereas am inserting a text with hyperlink into powerpoint using c# ,and am reading the hyperlink back from the powerpoint by the below method.
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (var item in presentation.Slides[i + 1].Shapes)
{
var shape = (PPT.Shape)item;
if (shape.HasTextFrame == MsoTriState.msoTrue)
{
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
var textRange = shape.TextFrame.TextRange;
var text = textRange.Text;
string address=textRange.ActionSettings[PPT.PpMouseActivation.ppMouseClick].Hyperlink.Address;
}
}
}
}
where am getting the hyperlink address in the variable address, likewise i need to get the hyperlink from the image which i have inserted into PPT using c#.
Is it possible.??
One option would be to iterate through Shapes on a Slide and see, whether they contain hyperlink. Or you should give your picture an id when creating it and then find it by the given id.
This code will display all hyperlinks on slide 1. Also it would be interesting to use Open XML SDK for this purpose instead of automation.
Interesting link:
http://www.aspose.com/docs/display/slidesnet/Finding+a+Shape+in+a+Slide
EDIT:
I suggest you first modify the code that creates the image with hyperlink like this:
Then when you read the file you can use tags or name to distinguish shapes: