PPT2000: Macros Disabled When You Open Presentations Programatically (271898)
The information in this article applies to:
- Microsoft PowerPoint 2000
This article was previously published under Q271898 SYMPTOMS
In Microsoft Visual Basic for Applications (VBA), when you use the Presentations.Open method in one presentation to open another presentation that contains macros, PowerPoint opens the new presentation, but disables all of the macros. There is no way to change this behavior in the Presenations.Open method.
CAUSE
Typically, when you open a presentation that contains macros, you receive the Macro Warning dialog box. However, the Macro Warning dialog box does not appear when you use the Presentation.Open method in VBA. The Presentation.Open method has no option to open a presentation and run its macros.
This behavior is designed to protect your computer from malicious code.
WORKAROUNDMicrosoft 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. Sample Code
The following sample code opens a PowerPoint presentation, and then closes the current, active presentation. If the new presentation contains macros, you receive a macro virus warning.
To accomplish this, the macro creates a batch file and opens the new presentation by using the batch file, instead of the Presentations.Open method.
Sub NextPres()
'
' Purpose: You can use this macro to follow a hyperlink to another
' presentation, and close the current, active presentation.
' Typically, PowerPoint leaves the current presentation
' open when it follows a hyperlink.
'
' Result: This macro calls the next presentation in line
' (strPath). It then closes this presentation.
'
' NOTE: If the presentation that is being called contains a
' macro, you are presented with the macro warning
' dialog box.
'
Dim strPath As String
Dim strPPT As String
Dim lngRet As Long
Dim presMe As Presentation
' Capture the active presentation.
Set presMe = ActivePresentation
' Set the path to the PowerPoint executable file.
strPPT = Chr(34) & "c:\program files\microsoft " _ &
"office\office\powerpnt.exe" & Chr(34)
' Set the path to the "next" presentation to link to.
' NOTE: This is in the same "path" as the active presentation.
strPath = presMe.Path & "\Next.ppt"
' Create a batch file in the path of the active presentation.
Open presMe.Path & "\ppt.bat" For Output As #1
' Write the full path of the PowerPoint .exe file, followed by the
' full path to the next file.
' NOTE: The "/s" is added to the path so that PowerPoint
' opens in slide show mode.
Print #1, strPPT & " /s " & strPath
Close #1
' Run the batch file made above.
lngRet = Shell(presMe.Path & "\ppt.bat")
' Minimize the PowerPoint window.
Application.WindowState = ppWindowMinimized
' Close the current presentation.
presMe.Close
End Sub
STATUS
This feature is under review and will be considered for inclusion in a
future release.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kbnofix KB271898 |
---|
|