So I have a task to do in Excel for Mac, using VBA :
At the press of a button, I need to read data from a Worksheet in Excel, parse the values and export them to a web server, which reads the data and write it in a file on the server. On Windows, everything went smoothly, using MSXML2.ServerXMLHTTP and all, but on Mac it is not possible to do so (This kind of object is part of ActiveX).
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
objHttp.SetOption 2, objHttp.GetOption(2) - SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
objHttp.Open "POST", myURL, False
objHttp.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHttp.SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.SetRequestHeader "Authorization", "Basic " & Base64Encode(Username & ":" & Password)
objHttp.Send (strOutput)
From this thread : How can I send an HTTP POST request to a server from Excel using VBA?, I tried using Query Tables without any success (I always got the "server not found" error, even though I triple checked the address and all.)
With ActiveSheet.QueryTables.Add(Connection:="URL;https://myurl.com/index.php", Destination:=Range("K1"))
.PostText = strOutput
.RefreshStyle = xlOverwriteCells
.SaveData = True
.Refresh
End With
I also tried to send the data through a curl command, but I can't seem to find how to execute it correctly from within VBA.
sCmd = "curl " & _
"-u " & Username & ":" & Password & _
" -d " & Chr(34) & data & Chr(34) & _
" " & url
So if anyone has an idea on how I should do that task, I would be really grateful. Thanks a lot.
EDIT : Added my failed attempts
See Question&Answers more detail:os