Prev: Widening line spacing in text box
Next: Increase notes font, text doesn't autofit into placeholder
From: Yoni on 24 Mar 2010 09:26 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
From: Steve Rindsberg on 24 Mar 2010 12:33 In article <1B9768B5-8DF4-417D-8962-9792AAF8BB5C(a)microsoft.com>, Yoni wrote: > 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. For a link w/in the same presentation, you'd want to set the Hyperlink.SubAddress rather than .Address I don't C# (too much VBA has left me astigmatic, I guess), but in case it helps, this works (VBA): With ActivePresentation.Slides(1).Shapes("Table 3") With .Table With .Cell(1, 1).Shape.TextFrame With .TextRange .Text = "Link me here" With .ActionSettings(ppMouseClick) .Action = ppActionHyperlink .Hyperlink.SubAddress = "Two" End With End With End With End With End With It creates a link to the second slide in the presentation, whose title text is "Two". It'd be more reliable to use .Hyperlink.SubAddress = "257,2," or .Hyperlink.SubAddress = ",2," 257 is the SlideID of the slide you're linking to, 2 is the SlideIndex ============================== PPT Frequently Asked Questions http://www.pptfaq.com/ PPTools add-ins for PowerPoint http://www.pptools.com/
|
Pages: 1 Prev: Widening line spacing in text box Next: Increase notes font, text doesn't autofit into placeholder |