I'm trying to access a .csv file stored in my company's sharepoint from a VBA function in an Excel file stored on my laptop locally:
FilePath = "https://[company].sharepoint.com/Shared%20Documents/[folder]/testCSV.csv"
Open FilePath For Input As #1
the function i've written works fine if the .csv file is saved locally in my laptop but gives this error when trying through SharePoint :
Run-Time Error '52':
Bad file name or number
The funny thing is that I can actually open the same .csv file as an Excel workbook with this code :
Dim FilePath As String
FilePath = "https://[company].sharepoint.com/Shared%20Documents/[folder]/testCSV.csv"
Dim wb As Workbook
Set wb = Workbooks.Open(FilePath, , , 2)
I've tryied as well to open a .txt file with this code :
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("https://[company].sharepoint.com/Shared%20Documents/[folder]/testfile.txt", ForAppending)
f.Write "Hello world!"
f.Close
and again works fine if the file is saved on my computer but not if it's saved on sharepoint
Any ideas on how to solve the issue ?
Thanks in advance