PPT98: Sample Code to Batch Convert Files to PowerPoint 98 Format (183957)



The information in this article applies to:

  • Microsoft PowerPoint 98 Macintosh Edition

This article was previously published under Q183957

SUMMARY

This article contains a sample Microsoft Visual Basic for Applications macro that converts all Microsoft PowerPoint presentations in a specific folder to the PowerPoint 98 format.

MORE INFORMATION

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.

Operational Constraints

The following sample macro code has the following operational constraints:
  • It converts files in one folder only. In other words, it does not convert files in subfolders or whole drives.
  • It has no user interface.
  • It converts files that are already saved in PowerPoint 98 format. Therefore you should move PowerPoint 98 files to another folder to speed up the conversion process.
  • It does not convert templates or stationery pad files.
  • It does not overwrite the original files. Because it creates a new file in the same folder as the original file, make sure you have enough disk space before you run the macro.
  • It fails if there is insufficient memory available for PowerPoint to open and convert a presentation. Therefore, make sure you have allocated enough memory for PowerPoint to convert the largest file in the folder.

Preparing Files and Running the Macro

  1. Copy or move the presentations you want to convert to a single folder.
  2. Copy a presentation that contains the macro to the same folder. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

    181058 OFF98: How to Run Sample Code from Knowledge Base Articles

  3. Open the presentation that contains the VBA macro. The macro will automatically determine that you want to convert files in the current folder.
  4. Run the BatchConvert macro.
When the macro has finished, every file in the folder will be converted. Each new file name is appended with 98. For example, if you converted a file called "My File" you will have an additional file called "My File 98."

The Code

Sub BatchConvert()

   ' Declare variables.
   Dim i as Integer
   Dim oPres As Presentation
   Dim strPath As String

   ' Get the path of the active presentation.
   strPath = ActivePresentation.Path

   ' Make sure that path is not an empty string.
   If "" = strPath Then
      MsgBox "The Active presentation does not have a path. The " _
         & "presentation may not be saved. Please open a presentation " _
         & "from the location that has the presentations you want to " _
         & "convert."
      End
   End If

   ' Search for presentations.
   With Application.FileFind

      ' Set up the search criteria.
      .SearchPath = strPath
      .Options = msoOptionsNew
      .FileType = msoFileTypePowerPointPresentations
      .SearchSubFolders = False

      ' Start the search.
      .Execute

      ' Check to see if the search returned any files.
      With .FoundFiles

         If .Count > 0 Then

            ' Loop through the found presentations.
            For i = 1 To .Count

               ' Open the Presentation
               Set oPres = Presentations.Open(.Item(i))

               ' Save the presentation and append 98 to the end of
               ' the presentation name.
               oPres.SaveAs oPres.Name & " 98", ppSaveAsPresentation

               ' Close the presentation.
               oPres.Close

            Next i

            ' Display a dialog box that indicates how many presentations
            ' were converted.
            MsgBox "Converted " & .Count & " presentations."

         Else

            MsgBox "No PowerPoint" _
               & " files were found."

         End If

      ' End the FoundFiles With statement.
      End With

   ' End the FileFind With statement.
   End With

   End Sub
				

REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

163435 VBA: Programming Resources for Visual Basic for Applications


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbcode kbconversion kbdtacode kbhowto kbmacroexample KB183957