Adding an Attachment to a Sharepoint List item using VBA

G

Guest

I am developing an Access 2003 application for my company that is using
Sharepoint as a repository for customer complaints. From within Access 2003 I
have provided a text box from which they can select a file on the users local
PC and would like to have that file uploaded to a sharepoint and a specific
list item (for testing purposes I am using the first record in that list). I
have used the Web references to create class library, however when I call the
ADDATTACHMENT method, I get an runtime error as shown below:

Run-time error '-2147024809 (80070057)':

WSDLReader:XML Parser failed as linenumber 0, lineposition 0, reason
is: The system cannot locate the object specified.
HRESULT=0x1: Incorrect Function.
- WSDLReader:Loading of the WSDL file failed
HRESULT=0x80070057: The parameter is incorrect.
- Client:One of the parameters supplied is invalid.
HRESULT=0x80070057: The parameter is incorrect.

This is a cryptic message that does not tell me much about what I did wrong.
I followed the sketchy documentation for using the Web Services Toolkit,
tried different values for the parameters, but......

The VBA code I am using is:

Public Function sppaddattachment(Optional strList As String, _
Optional strFPIRid As String, _
Optional strFileUrl As String)

Dim BaseWeb As New clsws_Lists
Dim strStatus As Variant

strFileUrl = "c:\roi\950-207-1200.xls"
strList = "\sites\imfcstrain\tblFPIRData"
strFPIRid = "1"

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(strFileUrl) Then
MsgBox strFileUrl & " is not found"
Exit Function

End If

strStatus = BaseWeb.wsm_AddAttachment(strList, _
strFPIRid, strFileUrl, FileToByte(strFileUrl))

End Function

Public Function FileToByte(fname As String) As Byte()
Dim fnum As Integer
fnum = FreeFile
On Error GoTo FileErr
Open fname For Binary Access Read As fnum
On Error GoTo 0
Dim byt() As Byte
ReDim byt(LOF(fnum) - 1)
byt = InputB(LOF(fnum), fnum)
Close fnum
FileToByte = byt
Exit Function
FileErr:
MsgBox "File error: " & Err.Description
End Function

Can you please help and shed some light as to what I am doing wrong. I am
desperate as I have been struggling with this for the past few weeks.

Thanks...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top