Android Code Snippet Call a PHP Script from Excel (VB) and send/receive data


Licensed User
(this is not b4a but vba. Very useful f.e. getting statistic data from your b4a app using MySQL)

Execute this (f.e. add a button to your sheet and insert the code in "Button.Click()" ):

   Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
   URL = "" & ActiveWorkbook.Worksheets(1).Range("A1").Value
   objHTTP.Open "GET", URL, False
   objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
   objHTTP.send ("")
   ActiveWorkbook.Worksheets(1).Range("A3").Value = objHTTP.responseText
   Set objHTTP = Nothing
This will call the script my.php and sends the content of A1 to it. The answer is stored in A3

In PHP you simply get "name" by:


$name = $_GET["Name"];
echo "The name was: $name"

What is it good for? F.e. get statistic data from your webserver

Tags: Excel VBA PHP