How to Pass byte[] from Excel vba to web service -
i want pass byte[] excel vba web service.
below code convert file byte[].
dim bytfile() byte bytfile = getfilebytes("c:\test.doc")
below code used call webservice. bytfile parameter
dim xmlhttp object: set xmlhttp = createobject("microsoft.xmlhttp") xmlhttp.open "post", service + "/passexceldata", false xmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded" xmlhttp.send "filebyte=" & bytfile
but not able pass webservice. getting error @ last line. want possible? if not, way can achieve this?
i have tried below code
function filetostr(byval strfile string) string dim hfile long hfile = freefile open strfile input #hfile filetostr = input$(lof(hfile), hfile) close #hfile end function
and called as:
xmlhttp.send "filebyte=" & filetostr(file path).
but returned below error:
you can't append byte array & operator. text of file using use function
function filetostr(byval strfile string) string dim hfile long hfile = freefile open strfile input #hfile filetostr = input$(lof(hfile), hfile) close #hfile end function
and xmlhttp.send "filebyte=" & filetostr("path file")
you can comment out getfilebytes line
Comments
Post a Comment