Microsoft KB Archive/251061

From BetaArchive Wiki

Article ID: 251061

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft PowerPoint 98 for Macintosh



This article was previously published under Q251061

SUMMARY

The Sub procedures in this article create a PowerPoint 98 Macintosh Edition add-in that allows you to save your presentation in the PowerPoint 95 for Windows, Version 7.0 file 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. NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Creating the Add-in

To create the add-in, follow these steps:

  1. Open a new presentation in PowerPoint.
  2. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  3. In the Visual Basic Editor, click Module on the Insert menu.
  4. Type the following Visual Basic for Applications code in the module:

    Sub Save_As_95()
    ' Calls the Error Routine.
       On Error GoTo save_err
       
       Dim strPresName As String
       Dim strReturnName As String
       Dim strPathName As String
       Dim strFullName As String
       Dim strOS As String
       Dim iResult As Integer
    
    ' Get Presentation Name and Path.
       strPresName = ActivePresentation.Name
       strPathName = ActivePresentation.Path
       
    ' Prompt for new file name for presentation.
       strReturnName = InputBox("Enter New Name for file:", "Save As" _
         & " PowerPoint 95", strPresName)
       
    ' If not empty then proceed.
       If strReturnName <> "" Then
       
    ' If the names are the same, prompt for confirmation to overwrite the file.
          If strReturnName = strPresName Then
             iResult = MsgBox("You did not change the file name," _
               & " do you wish to continue?", vbOKCancel, "Duplicate Name")
          Else
          
    ' If the names are not the same, then set iResult to OK.
             iResult = vbOK
          End If
          
    ' If iResult = OK then proceed.
          If iResult = vbOK Then
          
    ' Get the version of the operating system (OS).
             strOS = Application.OperatingSystem
             
    ' If the OS is Windows, make a Windows-based path and file name. Otherwise
    ' make a Macintosh file name.
             If InStr(strOS, "Windows (32-bit)") <> 0 Then
                strFullName = strPathName & "\" & strReturnName & ".ppt"
             Else
                strFullName = strPathName & Chr(58) & strReturnName & ".ppt"
             End If
             
    ' Save the presentation as a PowerPoint 95 file and then let
    ' the user know the name and location where the file was saved.
             ActivePresentation.SaveAs strFullName, ppSaveAsPowerPoint7
             MsgBox "Presentation " & strReturnName & " is saved to " _
               & strPathName & ".", , "Saved File"
          End If
       End If
    
    Exit Sub
    
    save_err:
       
    ' Let the user know that they have to have a file open
    ' to use this Add-in.
       MsgBox "Must have Presentation Open to Use!", vbExclamation, _
         "No Presentation Open!"
    End Sub
                            
    Sub Auto_Open()
    
       Dim NewControl As CommandBarControl
       
       ' Store an object reference to a command bar.
       Dim ToolsMenu As CommandBars
       
       ' Figure out where to place the menu choice.
       Set ToolsMenu = Application.CommandBars
       
       ' Create the menu choice. The choice is created in the first
       ' position in the Tools menu.
       Set NewControl = ToolsMenu("File").Controls _ 
         .Add(Type:=msoControlButton, Before:=1)
       
       ' Name the command.
       NewControl.Caption = "Save As PowerPoint 95 Presentation"
       
       ' Connect the menu choice to your macro. The OnAction property
       ' should be set to the name of your macro.
       NewControl.OnAction = "Save_As_95"
    
    End Sub
                            
    Sub Auto_Close()
    
       Dim oControl As CommandBarControl
       Dim ToolsMenu As CommandBars
    
       ' Get an object reference to a command bar.
       Set ToolsMenu = Application.CommandBars
    
       ' Loop through the commands on the Tools menu.
       For Each oControl In ToolsMenu("File").Controls
    
             ' Check to see whether the comand exists.
             If oControl.Caption = "Save As PowerPoint 95 Presentation" Then
    
               ' Check to see whether action setting is set to Save_As_95.
               If oControl.OnAction = "Save_As_95" Then
    
                   ' Remove the command from the menu.
                   oControl.Delete
                End If
             End If
       Next oControl
    End Sub
                        
  5. On the Debug menu, click Compile VBAProject.
  6. On the File menu, click Close and Return to Microsoft PowerPoint.
  7. In PowerPoint, click Save As on the File menu, and save the presentation as PP98_2_PP95.ppt.
  8. On the File menu, click Save As. In the Save File as Type list, save the presentation as a PowerPoint Add-In (.ppa).
  9. On the File menu, click Close.
  10. On the Tools menu, click Add-Ins.
  11. Click Add New.
  12. Click PP98_2_PP95.ppa, and then click OK.


REFERENCES

For additional information about writing a PowerPoint add-in, click the article number below to view the article in the Microsoft Knowledge Base:

163461 PPT: How to Create a PowerPoint 97 Add-In



Additional query words: vba

Keywords: kbdtacode kbhowto KB251061