PPT98: Sample Code to Batch Convert Files to PPT 98 Format

ID: Q183957

The information in this article applies to:

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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Operational Constraints

The following sample macro code has the following operational constraints:

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, please see the following article in the
   Microsoft Knowledge Base:

      ARTICLE-ID: Q181058
      TITLE     : 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" (without the quotation marks). 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:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications

Additional query words: vbe update migration updating mac_ppt ppt98 ppt_98 powerpoint 8.00 mac_powerpt powermac powerpt
Keywords          : kbcode kbdta kbconversion kbdtacode kbmacroexample kbpptvba 
Version           : MACINTOSH:98
Platform          : MACINTOSH
Hardware          : MAC
Issue type        : kbhowto

Last Reviewed: May 17, 1999