问题
I have an excel workbook and I need to publish it in a SharePoint site using Excel VBA. So I created a method in a module using the below code:
Private sc_Lists As SoapClient30
Public c_WSDL_URL As String
Private Const c_SERVICE As String = "Lists"
Private Const c_PORT As String = "ListsSoap"
Private Const c_SERVICE_NAMESPACE As String = "http://schemas.microsoft.com/sharepoint/soap/"
Private Sub Class_Initialize()
Dim str_WSML As String
str_WSML = ""
Set sc_Lists = New SoapClient30
c_WSDL_URL = glb_URL
sc_Lists.MSSoapInit2 c_WSDL_URL, str_WSML, c_SERVICE, c_PORT, c_SERVICE_NAMESPACE
sc_Lists.ConnectorProperty("WinHTTPAuthScheme") = &H1
sc_Lists.ConnectorProperty("UseSSL") = True
sc_Lists.ConnectorProperty("AuthUser") = "username"
sc_Lists.ConnectorProperty("AuthPassword") = "pass"
End Sub
The problem is when I open the excel document and try to publish it then it asks for the credentials of my SharePoint site even though I have provided them in the code as can be seen above. What I need is to prevent asking credentials when publishing.
回答1:
I've had auth issues when attempting to push to SP using VBA; it is simply to fragile and finicky. One solution I've used at my work is instead to map the SP site as a network drive and simply save the file directly (like in this UC tutorial), thus avoiding this problem.
来源:https://stackoverflow.com/questions/12639071/publishing-an-excel-workbook-in-sharepoint-site