Article ID: 163301
Article Last Modified on 10/11/2006
Sub Driver()
Dim IsOpen As Boolean
' Check to see whether test.ppt is open.
IsOpen = IsPresentationOpen("test.ppt")
' Process the return value from IsPresentationOpen.
If IsOpen = True Then
MsgBox "The presentation is open.", vbInformation
Else
MsgBox "The Presentation is not open.", vbInformation
End If
End Sub
' Function Name: IsPresentationOpen()
' Arguments: A string that represents the name of the presentation.
' The string can include the full path or just the
' presentation name.
' Returns: True if the presentation is open
' False if the presentation is not open
Function IsPresentationOpen(strPresName As String) As Boolean
' An object reference to a presentation.
Dim oPresObject As Presentation
Dim boolIsFullPath As Boolean
' Check to see whether the full path was passed.
If (InStr(1, strPresName, ":\")) = 0 Then
boolIsFullPath = False
Else
boolIsFullPath = True
End If
' Loop through the open presentations.
For Each oPresObject In PowerPoint.Presentations
If boolIsFullPath = True Then
' Check for a match.
If (StrComp(oPresObject.FullName, _
strPresName, _
vbTextCompare) = 0) Then
IsPresentationOpen = True
Exit Function
End If
Else
' Check for a match.
If (StrComp(oPresObject.Name, _
strPresName, _
vbTextCompare) = 0) Then
IsPresentationOpen = True
Exit Function
End If
End If
Next oPresObject
' No match found.
IsPresentationOpen = False
End Function
176476 OFF: Office Assistant Not Answering Visual Basic Questions
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 8.00 ppt8 vba vbe macppt mac_ppt ppt98 powerpt
Keywords: kbcode kbdtacode kbhowto kbmacro kbprogramming KB163301