how to insert attachment in sharepoint list using ado access vba (1 Viewer)

atzdgreat

Member
Local time
Yesterday, 20:18
Joined
Sep 5, 2019
Messages
42
hi all. i dont know how to insert an attachment in sharepoint list using ado.

Code:
Dim objStream As ADODB.Stream
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim pdfPath As String
    Dim strSQl As String
    pdfPath = "C:\Users\xxxx\Documents\24-0001.pdf"
    Set objStream = New ADODB.Stream
    objStream.Type = 1
    objStream.Open
    objStream.LoadFromFile pdfPath
  
    Set conn = New ADODB.Connection
    Set conn = CurrentProject.Connection
    
    'get Organization
    Set rs = New ADODB.Recordset
    strSQl = "SELECT Attachments FROM FDRFMainRequestTable WHERE FDRFRefNum = '24-0001'"
    rs.Open strSQl, conn, adOpenKeyset, adLockOptimistic
    
    If rs.EOF Then
    Else
        rs.Fields("Attachments") = objStream.Read
        rs.Update
    End If
    
    rs.Close
    Set rs = Nothing
    
    conn.Close
    Set conn = Nothing
  
    Set objStream = Nothing
    MsgBox ("Done!")
 
I note that you have yet to receive a reply. I am writing this message to bump you up the list so that your question gets a second look.
 
hi all. i dont know how to insert an attachment in sharepoint list using ado.

Code:
Dim objStream As ADODB.Stream
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim pdfPath As String
    Dim strSQl As String
    pdfPath = "C:\Users\xxxx\Documents\24-0001.pdf"
    Set objStream = New ADODB.Stream
    objStream.Type = 1
    objStream.Open
    objStream.LoadFromFile pdfPath
 
    Set conn = New ADODB.Connection
    Set conn = CurrentProject.Connection
   
    'get Organization
    Set rs = New ADODB.Recordset
    strSQl = "SELECT Attachments FROM FDRFMainRequestTable WHERE FDRFRefNum = '24-0001'"
    rs.Open strSQl, conn, adOpenKeyset, adLockOptimistic
   
    If rs.EOF Then
    Else
        rs.Fields("Attachments") = objStream.Read
        rs.Update
    End If
   
    rs.Close
    Set rs = Nothing
   
    conn.Close
    Set conn = Nothing
 
    Set objStream = Nothing
    MsgBox ("Done!")
What happens when you run this code? Knowing that might help someone cue in on a possible suggested solution.
 
Does it have to be ADO? Can you try DAO?
 

Users who are viewing this thread

Back
Top Bottom