简体   繁体   中英

How to delete a excel file in Sharepoint Online using VBA

As per title, I am trying to write code that deletes an excel file from a sharepoint online folder, using only vba.

Since I am very new to VBA, I have no idea where to begin with

Something as the following code should work.

Please note that the Kill function does not move the file to the trash bin . Use with care!

Sub RemoveSharePointFile()

Dim folder As String, file As String, fulladdress As String

folder = "https://example.sharepoint.com/sites/test/"
file = "test.xls" 'must include extension

fulladdress = folder & file
Kill fulladdress 

MsgBox "File '" & file & "' was successfully deleted.", vbInformation

End Sub

on cmd create a local folder point to sharepoint with "net use" (net use x:\\collaborate.yousite.com@SSL\\sites...) then

delete the file from the local driver

kill x:\\yourfile.pfd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM