nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am running a macro that will open a file, add a few lines of data, save the file and close it and continue running.
However with 2-3 users using this file, when the macro runs its possible the file will open Read-Only, and will cause issues trying to save.
Is there a way that when it runs when the file opens, the user will receive a message telling them that the file is Read-Only and they need to tell the other users to get out of the file so they can continue?
thanks,
However with 2-3 users using this file, when the macro runs its possible the file will open Read-Only, and will cause issues trying to save.
Is there a way that when it runs when the file opens, the user will receive a message telling them that the file is Read-Only and they need to tell the other users to get out of the file so they can continue?
thanks,
Code:
Dim thisdate As Date
Dim x As Workbook
Dim y As Workbook
Dim FileY As String
Dim j As Long
Dim i As Long
Dim k As Long
Dim r As Variant
Dim Found As Range
Dim NewPath As String, OldFile As String, NewFile As String
thisdate = Date
FileYear = Year(thisdate)
FileY = [COLOR=#000000]"[/COLOR][URL="file:///\\USBTRWDCN9K9TW1\MENLO\Main%20Billing%20Desk%20Reports\Seal%20Logs\"][COLOR=#000000]\\USBTRWDCN9K9TW1\Reports\Seal Logs\[/COLOR][/URL]" & FileYear & "\Seal Log " & FileYear & ".xlsx"
Select Case True
Case Len(Dir(FileY)) > 0
Workbooks.Open FileY
Case Len(Dir("J" & Right(FileY, Len(FileY) - 1))) > 1
FileY = "J" & Right(FileY, Len(FileY) - 1)
Workbooks.Open FileY
Case Len(Dir("I" & Right(FileY, Len(FileY) - 1))) > 1
FileY = "J" & Right(FileY, Len(FileY) - 1)
Workbooks.Open FileY
Case Else
End Select
If Not Dir(FileY, vbDirectory) = vbNullString Then
Set y = Workbooks.Open(FileY)
Else
MsgBox "File Not Found", 48, "File Not Found"
Exit Sub
End If