Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate Upload with Access

Status
Not open for further replies.

SysDupe123

Technical User
Dec 17, 2003
74
US
I'm trying to use Access VBA to automate the upload of several files into several folders on Sharepoint. I found this code by Jeff Jones but I cannot get it to work.

-----Start Code---------
' Written by Jeff Jones 3-30-2004. Pure freeware, please redistribute.
'=================================

'Use this function call to upload a single file
WebUploadFile "C:\file.txt", " "domain\user", "password"

'Use this function call and constant to upload a directory and all it's subdirectories
Const basedir = "c:\temp"
WebUploadDir "", " "domain\user", "password"


'====================== WebDAV upload single file
Function WebUploadFile (file, url, user, pass)
Dim objXMLHTTP
Dim objADOStream
Dim arrbuffer
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.LoadFromFile file
arrbuffer = objADOStream.Read()
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "PUT", url, False, user, pass
objXMLHTTP.send arrbuffer
End Function


'====================== WebDAV upload directroy
Function WebUploadDir (dir, baseUrl, usr, pwd)
Set fso = CreateObject("Scripting.FileSystemObject")
If dir = "" Then dir = basedir
Set srcFolder = fso.GetFolder(dir)

Dim fl
Set files = srcFolder.files
For Each fl in files
Dim relpath
relpath = Right(fl.path,Len(fl.path)-Len(basedir)-1)
relpath = Replace(relpath, "\", "/")
WebUploadFile fl.path, baseUrl & relpath, usr, pwd
Next

Dim sf
Set subfold = srcFolder.SubFolders
For Each sf in subfold
Set f = fso.GetFolder(sf)
relpath = Right(f,Len(f)-Len(basedir)-1)
relpath = Replace(relpath, "\", "/")
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "MKCOL", baseUrl & relpath, False, usr, pwd
objXMLHTTP.send
WebUploadDir f , baseUrl, usr, pwd
Next
End Function
-----End Code------

I am getting a certificate authority is invalid or incorrect error. Does anyone know of a way to bypass this programmatically?

Thanks
 
I've found out how to get around it. I'm posting this for others to reference.

In the code

Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")

objXMLHTTP.SetOption 2, objXMLHTTP.GetOption(2) <-------Add This Line

objXMLHTTP.open "PUT", url, False, user, pass
objXMLHTTP.send arrbuffer
End Function

This command ignores certificate errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top