JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
I can't seem to catch the error when attempting to load a file from Sharepoint. If the file doesn't exist it pops up with the error:
My code:
is there a way to catch that error?
Appreciate any help
I can't seem to catch the error when attempting to load a file from Sharepoint. If the file doesn't exist it pops up with the error:
My code:
VBA Code:
Sub Test1()
Dim WB1 As Workbook, ActiveListWB As Workbook
Dim WS1 As Worksheet, WS2 As Worksheet
Dim WeekFolder As String
Set WB1 = ThisWorkbook
Set WS1 = WB1.Sheets("1")
Set WS2 = WB1.Sheets("2")
SharepointFolder = "https://xxxxxxx.sharepoint.com/Testfolder/"
SubFolder = "WC_" & Format(Range("B3"), "YYYYMMDD") & "/"
'MONDAY
MyFile = SharepointFolder & SubFolder & WS1.Range("D7") & ".csv"
Set ActiveListWB = Workbooks.Open(MyFile, ReadOnly:=True)
WS2.Range("A1:D2000").Value2 = ActiveListWB.Sheets(1).Range("A1:D2000").Value2
ActiveListWB.Close False
WB1.Activate
End Sub
is there a way to catch that error?
Appreciate any help