So I have used this code before to look at files when they were last saved locally, however when I attempt to use the same methodology when looking at a sharepoint website, I get an error at
and yes, the file is on the sharepoint web folder.
What am I missing?? Please help!!
Thanks in advance!
Code:
Filename = Dir(DefPath & "*" & Format(CurDate, "Mmmm") & "*.xls*, vbNormal)
What am I missing?? Please help!!
Code:
Sub Find_Last_Updated_Sharepoint_file()
Application.DisplayAlerts = False
Dim Cur_Date As Date
Dim Fname, DefPath As Variant
Dim Filename As String
CurDate = Workbooks("Testing.xlsm").Sheets("Sheet1").Range("B2")
DefPath = "http://sharepoint.website/"& Format(CurDate, "Mmmm") & "%20" & Format(CurDate, "yyyy") & "/"
Filename = Dir(DefPath & "*" & Format(CurDate, "Mmmm") & "*.xls*", vbNormal)
Do While Filename <> ""
If FileDateTime(DefPath & Filename) > dtLast Then
dtLast = FileDateTime(DefPath & Filename)
latestFile = DefPath & Filename
End If
Filename = Dir
Loop
Filename = Dir$(latestFile)
Fname = DefPath & Filename
If BookOpen(Filename) = False Then Workbooks.Open Filename:=Fname
Application.DisplayAlerts = True
End Sub
Thanks in advance!