I was wondering if someone could help me with a PowerPoint VBA issue that I have encountered. I have a system of two PowerPoint presentations that I have linked dynamically and interactively using VBA, and which open using an external VBS script in the same folder which plays the PowerPoints in presentation mode and resizes and positions them on the screen. The VBS script links to this sub which automatically runs the other linked subs:
Sub Open_Presentation_VEdit()
Dim Ret
Dim Ret2
Dim PPT1 As Object
Set PPT1 = CreateObject("PowerPoint.Application")
Dim PPT2 As Object
Set PPT2 = CreateObject("PowerPoint.Application")
Dim filePath As String
filePath = ActivePresentation.Path
Ret = IsWorkBookOpen(filePath & "\Stand Up Title Page - With Macros.pptm")
Ret2 = IsWorkBookOpen(filePath & "\Stand Up Summary and Breakdowns - With Macros.pptm")
If Ret = True And Ret2 = False Then
Set PPT1 = Presentations("Stand Up Title Page - With Macros.pptm")
Set PPT2 = Presentations.Open(filePath & "\Stand Up Summary and Breakdowns - With Macros.pptm")
Call TaskbarAutohideOn
Call Resize_Presentations
Else: MsgBox "Close all stand-up wall slides"
End If
End Sub
The problem I am having is that a function that I have, IsWorkBookOpen, is creating problems for allowing multiple users to the system:
Function IsWorkBookOpen(fileName As String)
Dim ff As Long, ErrNo As Long
On Error Resume Next
ff = FreeFile()
Open fileName For Input Lock Read As #ff
Close ff
ErrNo = Err
On Error GoTo 0
Select Case ErrNo
Case 0: IsWorkBookOpen = False
Case 70: IsWorkBookOpen = True
Case Else: Error ErrNo
End Select
End Function
I have this function written in because I was having problems with the opening sequence if someone pressed the script multiple times, lots of versions of the two PowerPoints tried to open which caused issues with the code and errors.
However, the system needs to be opened by multiple people at once, who are accessing this over a network. Is it possible to write a function that can tell if an individual user has the two presentations open? I.e. allow only one copy of each presentation to be open at one time by an individual user, but allow multiple users.
Thanks in advance for any help!