Access/VBA Library

CreateTempPresentation

Creates a copy of a file and puts it in the Temp folder.

Syntax

CreateTempPresentation( Filename )
Parameters
Name Type Description
Filename String Required. Name of the PowerPoint file to be copied.
Return value

String : The name of the temporary file created.

Code
Public Function CreateTempPresentation(Filename As String) As String
    Dim TempFilename As String
    Dim ExtensionName As String
    
    With FSO
        TempFilename = .GetSpecialFolder(2) & "\" & .GetFileName(Filename)
        
        If .FileExists(TempFilename) Then .DeleteFile TempFilename
        
        .CopyFile Filename, TempFilename
    
    End With
    
    CreateTempPresentation = TempFilename
End Function

PowerPointtag:PowerPoint

Remarks

  • This function is usefull to open a PowerPoint file without adding it to the Most Recent Used (MRU) list. Opening files from the Temp folder are not added to the MRU.

See also

  • FSO
Example
  Dim TempFile as String
  TempFile = CreateTempPresentation("C:\myfile.pptx")
  ' Copy slides to clipboard
  With Application_Presentations.Open(TempFile,msoFalse)
      .Slides.Range.Copy
      .Close
  End With
  FSO.DeleteFile TempFile