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!")