OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

How to print hyperlinked presentations

The conveniences of hyperlinks are well known and it's very common to see multiple presentations created which are then consolidated under on single presentation acting as menu system or point of origin. But when it comes to printing such a hyperlinked presentation there is not simple way to do it.

This macro is a step towards that. The macro enumerates all the hyperlinked presentations and then it's sets out to print them one by one.

Note: This code does not handle nested hyperlinks. i.e if you link Pres A to Pres B and the Pres B to Pres C. It will only print Pres A and Pres B but not Pres C. But it is a simple matter to extend it to handle it, if required.

 

Sub PrintHyperlinkedPresentations()
Dim oSld As Slide
Dim oPPT As Presentation
Dim iCount As Integer
Dim oPresCol As Collection
' This step is crucial since some of the paths can be relative.
' So the processing should always be with respect to the current
' folder of the parent presentation.
Call ChDir(ActivePresentation.Path)
' Create a collection containing the presentation paths.
Set oPresCol = New Collection
' Add the main presentation to the list.
' We assign the filename to the collection item as well as the key so a presentation
' is not printed twice.

oPresCol.Add LCase(ActivePresentation.FullName), _
                 LCase(ActivePresentation.FullName)
For Each oSld In ActivePresentation.Slides
    For iCount = 1 To oSld.Hyperlinks.Count
        If oSld.Hyperlinks(iCount).Address <> "" Then
            ' Do a basic check for a presentation check extension of the file
            If LCase(Right(oSld.Hyperlinks(iCount).Address, 3)) = "ppt" Or _
                    LCase(Right(oSld.Hyperlinks(iCount).Address, 3)) = "pps" Then
                'Add the presentation to the collection to be printed
                oPresCol.Add LCase(oSld.Hyperlinks(iCount).Address), _
                                LCase(oSld.Hyperlinks(iCount).Address)
            End If
        End If
    Next
Next
' Now print out each presentation using your desired properties
For iCount = 1 To oPresCol.Count
    Debug.Print oPresCol(iCount)
    Set oPPT = Application.Presentations.Open(oPresCol(iCount), True, , False)
    With oPPT.PrintOptions
        .OutputType = ppPrintOutputSlides
        .PrintHiddenSlides = False
        .FitToPage = True
    End With
oPPT.PrintOut
oPPT.Close
Next
Set oPPT = Nothing
End Sub


 

 

 

 


Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.