【发布时间】:2021-09-20 20:43:02
【问题描述】:
使用此代码将文件上传到 SharePoint 有一段时间了,前几天注意到上传文件时,它会自动签出给我自己,必须进入 SharePoint 并手动签入,以便其他人可以查看文件。有什么方法可以修改或添加到下面的代码以在文件上传后自动签入文件?完全被难住了,任何帮助将不胜感激。
Sub SharePointUpload()
Dim WSN
Dim spAdd
Set WSN = CreateObject("WScript.Network")
spAdd = "https://mysharepoint/test"
WSN.mapnetworkdrive "N:", spAdd
ActiveWorkbook.Save
Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object
' Where you will enter Sharepoint location path
SharepointAddress = "\\mysharepoint\test"
' Where you will enter the local file path
LocalAddress = "C:\data\sample_file.xlsm"
Set objNet = CreateObject("WScript.Network")
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(LocalAddress) Then
FS.CopyFile LocalAddress, SharepointAddress
Else: MsgBox "File does not exist!"
End If
Set objNet = Nothing
Set FS = Nothing
WSN.removenetworkdrive "N:"
End Sub
【问题讨论】: