How to read the hyper-link of an image in power Point using c#


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 <strong>address</strong>, 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.

private void GetHyperlink() { Microsoft.Office.Interop.PowerPoint.Application objApp = new Microsoft.Office.Interop.PowerPoint.Application(); objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; Presentations objPresSet = objApp.Presentations; Presentation p = objPresSet.Open("C:\test.ppt"); Slide slide = p.Slides[1]; // or Slide slide = objApp.ActiveWindow.View.Slide; for (int i = 1; i <= slide.Shapes.Count; i++) { //If the hyperlink address is filled then display it in MessageBox if (slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address != null) MessageBox.Show(slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address); } }

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:

<a href="http://www.aspose.com/docs/display/slidesnet/Finding+a+Shape+in+a+Slide" rel="nofollow">http://www.aspose.com/docs/display/slidesnet/Finding+a+Shape+in+a+Slide</a>


I suggest you first modify the code that creates the image with hyperlink like this:

//Add a picture Shape pic = slide.Shapes.AddPicture(@"C:\Users\Public\Pictures\Sample Pictures\koala.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height); //Here you have various options how to distinguish your shape pic.Name = "MyPic"; pic.AlternativeText = "Koala"; pic.Tags.Add("MyPic", "@http://www.google.com/"); //adding hyperlink, etc... pic.ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address =@"http://www.google.com/"

Then when you read the file you can use tags or name to distinguish shapes:

//tags check if (slide.Shapes[i].Tags.Count > 0 && slide.Shapes[i].Tags["MyPic"]!=null && slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address != null) MessageBox.Show(slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address); //or //name check if (slide.Shapes[i].Name.Equals("MyPic", StringComparison.InvariantCultureIgnoreCase) && slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address != null) MessageBox.Show(slide.Shapes[i].ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address);


  • ReplaceWith carousel-inner with new items
  • How to push ViewController with slide effect from left to right? Animation name required
  • Transition height onload of d3js rect svg
  • Bootstrap Carousel Next/Prev not working
  • Crafting a LINQ based solution to determine if a set of predicates are satisfied for a pair of colle
  • how to remove a div with same ids but display='block' and display='none' in JAVa
  • Delphi: Where is the shortcut that started the application? [duplicate]
  • can variables be set randomly when declaring them again?
  • Validate jQuery plugin, field not required
  • Thread 1: EXC_BAD_ACCESS (code =1 address = 0x0)
  • msbuild create itemgroup from property group
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • How do I access an unhandled exception in an MVC Error view?
  • Meteor: Do Something On Email Verification Confirmation
  • Google Custom Search with transparent background
  • Cannot resolve symbol 'MyApi'
  • Initializer list vs. initialization method
  • Control modification in presentation layer
  • Linq Objects Group By & Sum
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Optimizing database types to compact database (SQLite)
  • Fetching methods from BroadcastReceiver to update UI
  • vba code to select only visible cells in specific column except heading
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • AT Commands to Send SMS not working in Windows 8.1
  • How to format a variable of double type
  • How to delete a row from a dynamic generate table using jquery?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • json Serialization in asp
  • Buffer size for converting unsigned long to string
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • using HTMLImports.whenReady not working in chrome
  • How to stop GridView from loading again when I press back button?
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • reshape alternating columns in less time and using less memory
  • How to Embed XSL into XML
  • To Get the radio button value in ruby on rails