通过 VBA 将文档上传到 SharePoint
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24782138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upload document to SharePoint via VBA
提问by user3845232
I have this code to upload a document to SharePoint via VBA by mapping it to a drive.
我有这个代码通过 VBA 将文档映射到驱动器来上传到 SharePoint。
I get
我得到
"Compile error, Sub or function not defined".
“编译错误,未定义子函数或函数”。
Then it highlights the second quote mark from this line:
然后它突出显示这一行的第二个引号:
objNet.MapNetworkDrive “A: ” , SharepointAddress
Below is the entire subroutine.
下面是整个子程序。
Sub UploadToSharepoint()
Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object
SharepointAddress = "http://share.deere.com/teams/sm_at_sd/suppcaptracking/Test"
LocalAddress = ”c: MyWorkFiletoCopy.xlsx”
Set objNet = CreateObject(“WScript.Network”)
Set FS = CreateObject(“Scripting.FileSystemObject”)
objNet.MapNetworkDrive “A: ” , SharepointAddress
If FS.FileExists(LocalAddress) Then
FS.CopyFile LocalAddress, SharepointAddress
End If
objNet.RemoveNetworkDrive “A: ”
Set objNet = Nothing
Set FS = Nothing
End Sub
回答by Tom37
Your Quotation marks look a little strange in the area in question : ”
.
您的引号在相关区域中看起来有点奇怪:”
。
Delete ”
and replace them with the ones "
that you have used for the shapepointaddress =...
variable.
删除”
它们并将其替换"
为您用于shapepointaddress =...
变量的那些。
回答by Christophe
I would expect:
我希望:
SharepointAddress = "\share.deere.com\teams\sm_at_sd\suppcaptracking\Test"