Link to other slides from table using c#

Y

Yoni

Hi,

I'm looking to create links from a certain slide to another, and I need
those links to be from within a table.

I need it to be something like this:



var
pptApp = new
PowerPoint.Application();

var
presentation = pptApp.Presentations.Add(Office.MsoTriState.msoFalse);
var
slides = presentation.Slides;

slides.InsertFromFile(@"C:\Users\Tng1\Documents\PresentationTemplate.potx"
, 0, 1);
var
titleSlide = slides[1];
titleSlide.Name="TitleSlide"
;

var
tableSlide = slides[2];
tableSlide.Name = "TableSlide"
;
var
shapes = tableSlide.Shapes;
var
table = shapes[2].Table;
var
cellTextFrame = table.Cell(1, 1).Shape.TextFrame;
cellTextFrame.TextRange.Text = "Link To Title Slide"
;
var
cellAction =
cellTextFrame.TextRange.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick];
cellAction.Action = PowerPoint.PpActionType.ppActionHyperlink;
cellAction.Hyperlink.Address = "titleSlide"
;

presentation.SaveAs(@"C:\Users\Tng1\Documents\Presentation.pptx"
, PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation,
Office.MsoTriState.msoTrue);

However, when i set the action property:

var
cellAction =
cellTextFrame.TextRange.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick];
cellAction.Action = PowerPoint.PpActionType.ppActionHyperlink;

It throws the 0x80004005 COM exception.
I should tell you that when doing this in a simple text frame (not from a
table) it works.

I'm using Office Enterprise 2007, and have reproduced the problem on XP SP3
with VS 2008 Team Edition, and on Win7 with VS 2010 RC.

Thanks,

Yoni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top