Microsoft KB Archive/274702

From BetaArchive Wiki

Article ID: 274702

Article Last Modified on 1/29/2007



APPLIES TO

  • Microsoft PowerPoint 2001 for Mac



This article was previously published under Q274702


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 2001 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 2001 format. Therefore you should move PowerPoint 2001 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:

    274703 OFF2001: 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 2001. For example, if you converted a file called "My File" you will have an additional file called "My File 2001."

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
      ' NOTE: Filetype may need to be set to SLD8 or PPT3, depending on 
      ' your settings in FileExchange. SLD3 is more common.
      .FileType = MacID("SLD3")
      .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 2001 to the end of
               ' the presentation name.
               oPres.SaveAs oPres.Name & " 2001", 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
                


Additional query words: vbe update updating mac ppt powerpt powermac ppt2001 PPT2001KB macro automation automatic vba

Keywords: kbcode kbconversion kbdtacode kbinfo kbmacroexample KB274702