Hi all
We've recently migrated a spreadsheet from our server to a sharepoint location. When it was on the server I wrote some code to open the last instance of the file (a new version is created weekly), which is pasted below. The path location is now https://tempworks.sharepoint.c…ments/General/Resourcing/ then I want the code to open the latest saved version, which is currently 220721%20-%20Team%20Resource%20Planner.xlsx?web=1
Appreciate any assistance on this.
Code
Sub OpenResources()
' Opens latest saved version of resource spreadsheet
Application.ScreenUpdating = False
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
On Error GoTo ErrHandler
MyPath = "P:\4. Technical\3. Resourcing\"
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
MyFile = Dir(MyPath & "*.xlsx", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No files were found", vbExclamation
Exit Sub
End If
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
End If
MyFile = Dir
Loop
Workbooks.Open MyPath & LatestFile
ErrHandler:
On Error Resume Next
Application.ScreenUpdating = True
End Sub
Display More