Joel's SharePoint Architect Blog

SharePoint 2010, MOSS & WSS Tips and Consultancy Tales

Subscribe Subscribe  View Joel Jeffery's profile on LinkedIn
joelblogs.co.uk | joelj.co.uk | joeljeffery.co.uk | jfdiphoenix.co.uk

Posts Tagged ‘Macro’

*UPDATE* Here’s the download link to a new version of my PowerPoint template with VBA Macro, updated to auto generate hyperlinks and summary pages for your PowerPoint 2010 slide decks.

In my first post on creating Auto Summary Slides for PowerPoint 2010, I gave you a VBA macro and PowerPoint template showing how to create summary slides based upon the titles of those selected with one mouse click.

By popular demand, I’ve added an extra feature to the Macro. You now have two choices: either have the original behaviour of a text-only summary page, or use the new extended version that makes every summary item a hyperlink to the original slide.

Once again, I’m making this free under the Creative Commons Public Domain license.

Creative Commons Zero - CC0

   1: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   2: ''' InsertSummary()

   3: ''' by Joel Jeffery (http://joelblogs.co.uk) August 2010

   4: ''' Creates a Summary Slide for PowerPoint 2010

   5: ''' (and probably 2007 too!)

   6: ''' Depends: Requires QSortInPlace by Chip Pearson

   7: ''' Usage: Select Slides (e.g. in Slide Sorter) and run

   8: ''' this macro.

   9: ''' License: Creative Commons Public Domain 2010

  10: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  11: Sub InsertSummary(Optional CreateHyperlinks As Boolean)

  12:     Dim i As Integer

  13:     Dim strSel As String, strTitle As String

  14:     Dim summary As Slide

  15:     

  16:     'Only run if we've got something selected

  17:     If ActiveWindow.Selection.SlideRange.Count > 0 Then

  18:         'Array to hold the order of the slides...

  19:         'We do this or we build the ToC in the order

  20:         'in which the slides were selected :)

  21:         Dim slideOrder() As Integer

  22:         

  23:         'Size this to the number of slides selected

  24:         ReDim slideOrder(1 To ActiveWindow.Selection.SlideRange.Count)

  25:         

  26:         'Collect all the IDs of the selected slides

  27:         For i = 1 To ActiveWindow.Selection.SlideRange.Count

  28:             slideOrder(i) = ActiveWindow.Selection.SlideRange(i).SlideIndex

  29:         Next

  30:         

  31:         'Sort them with the QSort Algorithm

  32:         'By Chip Pearson, www.cpearson.com, chip@cpearson.com

  33:         QSortInPlace slideOrder

  34:                 

  35:         'Iterate over the slides in Index order

  36:         For o = 1 To UBound(slideOrder)

  37:             If ActivePresentation.Slides(slideOrder(o)).Shapes.HasTitle Then

  38:                 'Build up the ToC Text

  39:                 strTitle = ActivePresentation.Slides(slideOrder(o)).Shapes.Title.TextFrame.TextRange.Text

  40:                 strSel = strSel & strTitle & vbCrLf

  41:             End If

  42:         Next

  43:         

  44:         'Create the summary slide before the first slide in the selection

  45:         Set summary = ActivePresentation.Slides.Add(slideOrder(1), ppLayoutText)

  46:         'Add the title

  47:         summary.Shapes(1).TextFrame.TextRange = "Module Summary"

  48:         'Add the ToC text

  49:         summary.Shapes(2).TextFrame.TextRange = strSel

  50:         

  51:         ' By popular demand...! ;)

  52:         If CreateHyperlinks Then

  53:             'Add Hyperlinks :)

  54:             For o = 1 To UBound(slideOrder)

  55:                 If ActivePresentation.Slides(slideOrder(o) + 1).Shapes.HasTitle Then

  56:                     'Build up the ToC Text

  57:                     strTitle = ActivePresentation.Slides(slideOrder(o) + 1).Shapes.Title.TextFrame.TextRange.Text

  58:                     With summary.Shapes(2).TextFrame.TextRange.Paragraphs(o).ActionSettings(ppMouseClick)

  59:                         .Action = ppActionHyperlink

  60:                         .Hyperlink.Address = ""

  61:                         .Hyperlink.SubAddress = ActivePresentation.Slides(slideOrder(o) + 1).SlideID & "," & ActivePresentation.Slides(slideOrder(o) + 1).SlideIndex & "," + strTitle

  62:                     End With

  63:                 End If

  64:             Next

  65:         End If

  66:     End If

  67: End Sub

  68:  

  69: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  70: ''' InsertSummaryWithHyperlinks()

  71: ''' by Joel Jeffery (http://joelblogs.co.uk) August 2010

  72: ''' Creates a Summary Slide for PowerPoint 2010

  73: ''' (and probably 2007 too!) with Hyperlinks

  74: ''' Usage: Select Slides (e.g. in Slide Sorter) and run

  75: ''' this macro.

  76: ''' License: Creative Commons Public Domain 2010

  77: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  78: Sub InsertSummaryWithHyperlinks()

  79:     InsertSummary CreateHyperlinks:=True

  80: End Sub

To the extent possible under law, Joel Jeffery has waived all copyright and related or neighbouring rights to InsertSummary() and InsertSummaryWithHyperlinks() Macros for PowerPoint 2010. This work is published from United Kingdom. Why am I bothering to licensed this under Creative Commons? Because some folks are selling similar functionality as a PowerPoint Add-In and I think it should be free. Enjoy!

Technorati Tags: Macro, PowerPoint 2010, VBA

*UPDATE* Please see part two of this blog post for an updated version that creates a auto summary slides for PowerPoint 2010 with hyperlinks!

Download the Create Summary Slide Macro PowerPoint 2010 slide deck here.

Not strictly SharePoint Architect related, but I cooked this VBA script up whilst working on my latest SharePoint 2010 Developer courseware.

In PowerPoint 2003 and earlier there was a button you could press that would automagically create a Summary Slide or Table of Contents Slide for you based upon slides you’d selected in Slide Sorter.

It got taken away in PowerPoint 2007, and it’s still missing in 2010! So tonight I wrote this macro. Apologies for any errors. It’s very, very late.

Creative Commons Zero - CC0

   1: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   2: ''' InsertSummary()

   3: ''' by Joel Jeffery (http://joelblogs.co.uk) August 2010

   4: ''' Creates a Summary Slide for PowerPoint 2010

   5: ''' (and probably 2007 too!)

   6: ''' Depends: Requires QSortInPlace by Chip Pearson

   7: ''' Usage: Select Slides (e.g. in Slide Sorter) and run

   8: ''' this macro.

   9: ''' License: Creative Commons Public Domain 2010

  10: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  11: Sub InsertSummary()

  12:     Dim i As Integer

  13:     Dim strSel As String, strTitle As String

  14:     Dim summary As Slide

  15:     

  16:     'Only run if we've got something selected

  17:     If ActiveWindow.Selection.SlideRange.Count > 0 Then

  18:         'Array to hold the order of the slides...

  19:         'We do this or we build the ToC in the order

  20:         'in which the slides were selected :)

  21:         Dim slideOrder() As Integer

  22:         

  23:         'Size this to the number of slides selected

  24:         ReDim slideOrder(1 To ActiveWindow.Selection.SlideRange.Count)

  25:         

  26:         'Collect all the IDs of the selected slides

  27:         For i = 1 To ActiveWindow.Selection.SlideRange.Count

  28:             slideOrder(i) = ActiveWindow.Selection.SlideRange(i).SlideIndex

  29:         Next

  30:         

  31:         'Sort them with the QSort Algorithm

  32:         'By Chip Pearson, www.cpearson.com, chip@cpearson.com

  33:         QSortInPlace slideOrder

  34:                 

  35:         'Iterate over the slides in Index order

  36:         For o = 1 To UBound(slideOrder)

  37:             If ActivePresentation.Slides(slideOrder(o)).Shapes.HasTitle Then

  38:                 'Build up the ToC Text

  39:                 strTitle = ActivePresentation.Slides(slideOrder(o)).Shapes.Title.TextFrame.TextRange.Text

  40:                 strSel = strSel & strTitle & vbCrLf

  41:             End If

  42:         Next

  43:         

  44:         'Create the summary slide before the first slide in the selection

  45:         Set summary = ActivePresentation.Slides.Add(slideOrder(1), ppLayoutText)

  46:         'Add the title

  47:         summary.Shapes(1).TextFrame.TextRange = "Module Summary"

  48:         'Add the ToC text

  49:         summary.Shapes(2).TextFrame.TextRange = strSel

  50:     End If

  51: End Sub

  52:  

To the extent possible under law, Joel Jeffery has waived all copyright and related or neighbouring rights to InsertSummary() Macro for PowerPoint 2010. This work is published from United Kingdom. Why am I bothering to licensed this under Creative Commons? Because some folks are selling similar functionality as a PowerPoint Add-In and I think it should be free. Enjoy!

You’ll also need the QSortInPlace method by Chip Pearson.

To use, simply select all the slides you want to use for your summary (for instance, in Slide Sorter view) and run the InsertSummary() macro.

PowerPoint 2010 Slide Sorter

Here’s the result:

PowerPoint Automatic Summary Page

One bullet point bearing the title of each slide you include.

Enjoy!

Technorati Tags: Macro, PowerPoint 2010, VBA