Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Create an index or table of contents (TOC) with links to a folder full of PPT files

Problem

You have a whole collection of PPT files you want to link to from a single PPT "menu" slide or presentation. While you can insert links, one by one, to each file in the folder where the PPT files are stored, that's tedious.

Solution

Macros to the rescue.

Run this macro and it'll produce a series of text shapes on the current slide, one per PPT file in the directory pointed to by targetFileSpec (which you'll need to edit below).

Each one also becomes a link TO the PPT file. For lots of files, you'll need to do a little reformatting/spacing and aligning, but this'll whip up the basic "index" page for you in under a second.

Sub MakeLotsOfLinks()

Dim TheTextBox As Shape
Dim FileName As String
Dim LinkRange As TextRange
Dim Top, Left, width, height As Double
Dim targetFileSpec As String

' EDIT THIS:  Replace the text between the equals signs
'                     with the path to the folder where your PPT files are stored
targetFileSpec = "D:\Test\*.PPT"

' Rather arbitrary starting positions for text box
Top = 18#
Left = 18#
width = 600#
height = 30#

' Get the first matching file
FileName = Dir$(targetFileSpec)

' And if somebody's home:
While FileName <> ""

    ' Add a textbox to hold the link
    Set TheTextBox =
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal, _
        Left, _
        Top, _
        width, _
        height)

    TheTextBox.TextFrame.TextRange.Text = FileName

    Set LinkRange = TheTextBox.TextFrame.TextRange.Characters(Start:=1, Length:=Len(FileName))
    LinkRange.ActionSettings(ppMouseClick).Hyperlink.Address = FileName

    ' Get the next file
    FileName = Dir$
    ' move the text box start position down
    Top = Top + height
Wend

End Sub

Or put the links in a table

If you prefer to have the links in a table, you can use the following code.

First, create a table with enough cells to hold the number of files you'll be linking to. Then with the table selected, run this:

Sub MakeLotsOfLinksInATable()

Dim FileName As String
Dim LinkRange As TextRange
Dim targetFileSpec As String

Dim aFileNames() As String
Dim oTable As Shape
Dim x As Long
Dim y As Long
Dim lPointer As Long

' EDIT THIS:  Replace the text between the equals signs
'                     with the path to the folder where your PPT files are stored
targetFileSpec = "c:\myfiles\*.PPT"

ReDim aFileNames(1 To 1) As String

' Fill the array with filenames
FileName = Dir$(targetFileSpec)

' And if files are found:
While FileName <> ""
    aFileNames(UBound(aFileNames)) = FileName
    FileName = Dir$
    ReDim Preserve aFileNames(1 To UBound(aFileNames) + 1) As String
Wend
' that leaves us with blank array entry; remove it:
ReDim Preserve aFileNames(1 To UBound(aFileNames) - 1) As String

' now use the table
Set oTable = ActiveWindow.Selection.ShapeRange(1)
lPointer = 1

For y = 1 To oTable.Table.Rows.Count
    For x = 1 To oTable.Table.Columns.Count
        oTable.Table.Cell(y, x).Shape.TextFrame.TextRange.Text = aFileNames(lPointer)
        Set LinkRange = _
          oTable.Table.Cell(y, x).Shape.TextFrame.TextRange.Characters(Start:=1, Length:=Len(aFileNames(lPointer)))
        LinkRange.ActionSettings(ppMouseClick).Hyperlink.Address = aFileNames(lPointer)
        lPointer = lPointer + 1
    Next    ' x
Next    ' y

End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.

Notes and Caveats

The links this produces are pathless, so you can move your collection of PowerPoint files from one computer to another easily. As long as your "index" PowerPoint file and all of the linked PPT files are together in the same folder, the links will work.

If the presentations are served from the web rather than a local drive, network drive or CD, the links won't work.

Also, due to a bug in PowerPoint, if you start PowerPoint then choose the index file from the Most Recently Used list on the File menu, PowerPoint doesn't properly set the default folder, so it won't find the linked files. Use any other method to open the presentation:


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Create an index or table of contents (TOC) with links to a folder full of PPT files
http://www.pptfaq.com/FAQ00291_Create_an_index_or_table_of_contents_-TOC-_with_links_to_a_folder_full_of_PPT_files.htm
Last update 07 June, 2011
Created: