Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Upload to Sharepoint programmatically

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,51051
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Upload to Sharepoint programmatically
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Upload to Sharepoint programmatically - 8/22/2007 6:06:09 AM   
  Sysdupe123

 

Posts: 6
Score: 0
Joined: 8/22/2007
Status: offline
I'm using Access VBA to automate some processes and I'm trying to upload files to Sharepoint.  I found some code but I'm running into a problem.  I'm getting an error about the certificate being invalid or incorrect.  When manually accessing the Sharepoint folder, I get a Security Alert.  Is there a way I can bypass the certificate?

Thanks

Code below......

' Written by Jeff Jones 3-30-2004.  Pure freeware, please redistribute.
'=================================
'Use this function call to upload a single file
WebUploadFile "C:\file.txt", "http://server/folder/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 "", "http://server/folder/", "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

 
 
Post #: 1
 
 RE: Upload to Sharepoint programmatically - 8/22/2007 6:58:57 AM   
  Parabellum


Posts: 222
Score: 0
Joined: 11/12/2006
From: UK
Status: offline
May need to upgrade to lates version of MSXML i know there were certifcate issues with v3 not sure about others..

if that doesnt work you can use the setOption Method with SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS
 
http://msdn2.microsoft.com/en-us/library/ms763811.aspx

(in reply to Sysdupe123)
 
 
Post #: 2
 
 RE: Upload to Sharepoint programmatically - 8/22/2007 7:44:59 AM   
  Sysdupe123

 

Posts: 6
Score: 0
Joined: 8/22/2007
Status: offline
Thanks Parabellum!

How would I use the Set Option Method?  I don't seem to be getting it.

(in reply to Parabellum)
 
 
Post #: 3
 
 RE: Upload to Sharepoint programmatically - 8/22/2007 7:55:18 AM   
  Sysdupe123

 

Posts: 6
Score: 0
Joined: 8/22/2007
Status: offline
Never mind, I've got it!

Thank you so much!  I've been trying to figure this out all week!

(in reply to Sysdupe123)
 
 
Post #: 4
 
 RE: Upload to Sharepoint programmatically - 9/4/2007 8:12:13 AM   
  Sysdupe123

 

Posts: 6
Score: 0
Joined: 8/22/2007
Status: offline
On a related issue, anyone know how to verify if a folder exists in Sharepoint?

(in reply to Sysdupe123)
 
 
Post #: 5
 
 RE: Upload to Sharepoint programmatically - 9/4/2007 8:37:55 AM   
  Parabellum


Posts: 222
Score: 0
Joined: 11/12/2006
From: UK
Status: offline
i think you can use the .Exists method, but would need to see some example to code to see how you would implement it.


(in reply to Sysdupe123)
 
 
Post #: 6
 
 RE: Upload to Sharepoint programmatically - 9/4/2007 9:26:50 AM   
  Sysdupe123

 

Posts: 6
Score: 0
Joined: 8/22/2007
Status: offline
The problem is that I don't know where to start.  I was thinking of some modification of the code for uploading files to Sharepoint.

(in reply to Parabellum)
 
 
Post #: 7
 
 RE: Upload to Sharepoint programmatically - 9/4/2007 10:39:26 PM   
  Parabellum


Posts: 222
Score: 0
Joined: 11/12/2006
From: UK
Status: offline
found this post... might be able to adapt..

http://forums.devx.com/showthread.php?t=6747

(in reply to Sysdupe123)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Upload to Sharepoint programmatically Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts