How can i read the details of a hyper links applied to the same presentation using open xml sdk 2.5. RRS feed

  • Question

  • I have created a presentation with two slides, the first slide has one shape with hyper link applied to the second slide. I want to get the details of that hyper link. I used the following code but i couldn't get the details , please help me how can i get that hyper link details?.


                    foreach (DataPartReferenceRelationship relationship in slidePart.DataPartReferenceRelationships)

                    foreach (ExternalRelationship relationship in slidePart.ExternalRelationships)

                    foreach (HyperlinkRelationship relationship in slidePart.HyperlinkRelationships)

    Saturday, October 26, 2013 10:48 AM


  • Hi,

    According to your description, I think you want to use the code to get the URI of the Hyperlink which is placed in a shape and the hyperlink is applied to the second slide.

    If the hyperlink is linked to a slide in the same presentation document, it will be an element of the shape object in the Open XML, and the URI of the hyperlink will be displayed as the Action property of the HyperlinkOnClick object.

    The XML of the hyperlink is as below, you could view it with the Open XML SDK 2.5 Productivity Tool.

      <p:cNvPr id="5" name="Oval 4">
        <a:hlinkClick r:id="" action="ppaction://hlinkshowjump?jump=nextslide" xmlns:r="" xmlns:a="" />
      <p:cNvSpPr />
      <p:nvPr />

    If the hyperlink is linked to, the HyperlinkRelationship object is a part of the SlidePart object instead of the Shape object. There is no HyperlinkRelationship object if you use the hyperlink which linked to a slide in the same presentation. So your code cannot achieve your goal.

    I write a sample to get the action property of the hyperlink for your reference.

    private static void GetDetailFromHyperLink()
        string FullPathName = @"C:\Users\Documents\pptHyperLink.pptx";
        using (PresentationDocument Pres = PresentationDocument.Open(FullPathName, false))
            // Get the relationship ID of the first slide.
            PresentationPart part = Pres.PresentationPart;
            OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements;
            string relId = (slideIds[0] as SlideId).RelationshipId;
            // Get the slide part from the relationship ID.
            SlidePart slide = (SlidePart)part.GetPartById(relId);
            if (slide != null)
                // Get the shape tree that contains the shape to change.
                ShapeTree tree = slide.Slide.CommonSlideData.ShapeTree;
                // Get the third shape in the shape tree.
                Shape shape = tree.Descendants<Shape>().ElementAt(2);
                if (shape != null)
                    NonVisualShapeProperties nonVisualShapeProperties1 = shape.NonVisualShapeProperties;
                    string hyperlinkAction = nonVisualShapeProperties1.NonVisualDrawingProperties.HyperlinkOnClick.Action.ToString();

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 29, 2013 3:20 AM