0

I am developing with C# application to create a PowerPoint presentation.

I am using the OpenXML SDK 2.0 and MS Office PP 2007.

I am able to clone my slides from my template and add a new shape on it.

But now i want to add a Hyperlink to my shape.

How can i do this?

I found this: tutorial but i need to add those hyperlinks at runtime.

I already tried this.

SlidePart currentSlidePart = CloneSlidePart(presentationPart, slidePart);
Slide s = currentSlidePart.Slide;
currentSlidePart.AddHyperlinkRelationship(new System.Uri("myuri", System.UriKind.Absolute), true, "rId2");

Then i called the method to create the shape:

s.CommonSlideData.ShapeTree.Append(generateTextShape("some content", shape));

And this is the method:

 public static Shape generateTextShape(String input, ShapePosition shapePosition)
 {
            Shape shape1 = new Shape();
...
            D.HyperlinkOnClick hyperlinkOnClick1 = new D.HyperlinkOnClick() { Id = "rId2" };
            nonVisualDrawingProperties1.Append(hyperlinkOnClick1);
...
    return shape1;
}

Right now, nothing happens.. What i am doing wrong, any suggestions?

(The class ShapePosition is just for x,y,width,height of a shape)

Best regards!

Leviathan
  • 282
  • 2
  • 12

1 Answers1

0

You said "nothing happens", so I'm not going to assume. Please try a few of these ideas:

1) Hyperlinks show in slide show mode. Put the presentation into slide show mode (Hit F5) - then click on the shape.

2) Did you append your nonVisualDrawingProperties1 to your shape1? To tell, right click on the shape in PP2007 and select hyperlink... see if your URL is there. If it is not there, then you need to make sure nonVisualDrawingProperties1 gets added to your shape1 in generateShapeText method.

3) if the URL is there, but it is not working, perhaps you have your relationship Ids incorrect?? In PP2007 with that same file, create a new simple shape, add a new hyperlink, save it with a new filename and compare the 2 files with the productivity tool. You should see the new hyperlink and relationship that PP2007 generated.

You posted partial code in generateShapeText. If you could put the complete code, that might help us troubleshoot this with you. -Cheers.

Taterhead
  • 5,763
  • 4
  • 31
  • 40
  • Hello Taterhead, i already forgot that question because i solved the problem. Sorry for that. The solution of the problem is pretty simply. If you are interested on the solution just let me know! I gonna update my question later. – Leviathan Nov 29 '13 at 15:35
  • 2
    @Leviathan Hi. Could you please update your question and include your solution? I happened to come across the same problem, and your solution will be very helpful :) Thanks. – Keith Jun 30 '16 at 10:48
  • @Leviathan there seem to be quite a few people wondering what the solution was here. It would be awesome if you could post your answer. It would also allow other people to up vote it if it helps them which would be cool for you :) Thanks – russelrillema May 22 '19 at 08:59
  • @russelrillema just ask a new question, link to this one, and post what you have tried and code and it will get answered – Taterhead May 22 '19 at 10:29
  • Cool, I am just trying out one or two more things using the power tools and if I don't come right I'll do that. Thanks – russelrillema May 23 '19 at 11:04