This is all for a save close button for a workbook 2010 loaded on sharepoint 2010. I have asked for help on this a couple time and have gotten this far, I am almost there.
I am having trouble with my "how many." I need it to display a message if there is already someone editing the file and if not go on to the ifelse statement
Thanks again
I am having trouble with my "how many." I need it to display a message if there is already someone editing the file and if not go on to the ifelse statement
Thanks again
Code:
Sub savebutton()
Dim Users As Variant
Dim HowMany As Integer
Users = ActiveWorkbook.UserStatus
HowMany = UBound(Users, 1)
If HowMany > 2 Then
'^^^^^^ I don't know how to write this properly
MsgBox "The file is currently open by Another RT. Please" & _
vbNewLine & "Check with your cooworkers."
'^^^^ dectect if someone is using the file, if so, display message, if not carry on.
ElseIf InStr(1, Application.Caption, "Read-Only") > 1 Then
ActiveWorkbook.LockServerFile
'^^^ disables server read only mode, script will fail if it gets here and someone else is editing the file or if read only mode has been disabled
ActiveWorkbook.Close
Application.Quit
Else
ActiveWorkbook.save
ActiveWorkbook.Close
End If
End Sub