Supercharge your PowerPoint productivity with

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

Tell me about PPTools

Use ShellExecute to sidestep certain linking problems


PPTools
Shape Styles brings the power of styles to PowerPoint. Apply complex formatting with a single click
Merge Excel, CSV or tab-delimited data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more
FixLinks prevents broken links when you distribute PowerPoint presentations
Optimizer saves disk space and bandwidth, shrinks your PowerPoint presentations to the right size for email, screenshow or printing
PPT2HTML gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements
Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF
Image Export converts PowerPoint slides to JPG, PNG, GIF, WMF and more

Problem

Some programs don't cooperate with PPT when you link to their files. The first release of Adobe Reader 7 is one example. When you set an Other File action setting in PowerPoint to open a PDF and click the link in slide show view, either nothing happens or you see a brief blink of Reader, which then disappears. And then nothing happens. (Note: this problem has been fixed in the 7.0.1 update to Reader).

Either way, you don't see the PDF you were expecting to view.

If you plan to run your presentation in PowerPoint, try the following VBA macro as a possible solution.
This won't work in the free PowerPoint viewers, and it won't work if your Macro security settings are on High.

To use it:

  • Assign a shape an Other File action setting and choose the file.
  • With the shape selected, run the AssignTag macro below. That will tag the shape with the name of the file to be launched, then assign the shape's action setting to be Run Macro: ShellExShape

Now put the file in SlideShow view and click the shape to see if it launches the document.

If it works, send a virtualkiss, money, whatever to Charles Wannall, whose post on the Adobe newsgroup suggested this workaround.

Solution

Option Explicit

Const SW_SHOWNORMAL As Long = 1

Declare Function ShellExecute Lib "shell32.dll" Alias _
         "ShellExecuteA" (ByVal Hwnd As Long, _
         ByVal lpOperation As String, _
         ByVal lpFile As String, _
         ByVal lpParameters As String, _
         ByVal lpDirectory As String, _
         ByVal nShowCmd As Long) As Long

Public Sub AssignTag()
' Select a shape and run me:

    With ActiveWindow.Selection.ShapeRange(1)
        If .ActionSettings(ppMouseClick).Hyperlink.Address <> "" Then
             Call .Tags.Add("FILENAME", .ActionSettings(ppMouseClick).Hyperlink.Address)
             .ActionSettings(ppMouseClick).Run = "ShellExShape"
        End If
    End With

End Sub

Public Sub ShellExShape(oSh As Shape)
' Assign this macro as the shape's action setting

   Dim sFileName As String

   On Error GoTo ErrorHandler

   ' Get the name of the file assigned to the shape as a tag
   sFileName = oSh.Tags("FILENAME")

   ' ShellExecute the file if one's listed
   If Len(sFileName) > 0 Then
      Call ShellExecute(0, "Open", sFileName, "", "C:\", SW_SHOWNORMAL)
   End If

NormalExit:
   Exit Sub
ErrorHandler:
   Resume NormalExit

End Sub

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

Search terms:


Page copy protected against web site content infringement by Copyscape Contents © 1995-2008 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.

Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese



Supercharge your PPT Productivity with PPTools


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

Use ShellExecute to sidestep certain linking problems
http://www.pptfaq.com/FAQ00689.htm
Last update 09 September, 2006