SYMPTOMS
When you use the
SaveAs method that is included with the Microsoft PowerPoint object model, you may receive the following error message:
Run-Time error '-2147483640 (80000008)
Presentation (unknown member): already exists and can't be replaced.
WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this problem, create a test to make sure the folder path is valid before you use the
SaveAs method. The following code sample illustrates this workaround:
Sub ValidateFolder()
' Create a variable to store path.
Dim strPath As String
strPath = "Macintosh HD:test:"
' Create a variable to hold the name of the presentation.
Dim strShowName As String
strShowName = "MyShow"
' Check if the folder exists.
If "" <> Dir(strPath, vbDirectory) Then
' The folder is valid, so save the file.
ActivePresentation.SaveAs strPath & strShowName, ppSaveAsShow
Else
' Place code to handle the case that the folder does not exist.
End If
End Sub
NOTE: The Dir() procedure does not validate your hard disk name. If you add a ":" after the hard disk name, Dir() returns the first folder in the root of your hard disk. If you pass Dir() the name of your hard disk without using the ":", it always returns "". The following code returns the first folder in the root of your hard disk:
strDirReturn = Dir("Macintosh HD:", vbDirectory)
Replace "Macintosh HD" with the actual name of your hard disk.