Q: Read text with VBA from a PHP web-page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jabe

    Q: Read text with VBA from a PHP web-page

    I created a page on our intranet that shows a number and that
    increases for every time the page is opened. It is similar to a
    visitors-counter.
    When I look at the page with Internet Explorer it works just fine.

    Now I want to read this web-page from a MS-Word macro and include the
    number as a company wide unique id in my MS-Word document.
    Unfortunately, the PHP script doesn't update the counter when I call
    it from my MS-Word macro.

    How can I force PHP to update my counter when I call it from a VBA
    macro?

    I am using the following code:
    [color=blue]
    > Put the following into the Declarations section of your program:
    > Declare Function URLDownloadToFi le Lib "urlmon" _
    > Alias "URLDownloadToF ileA" _
    > (ByVal pCaller As Long, ByVal szURL As String, _
    > ByVal szFileName As String, ByVal dwReserved As Long, _
    > ByVal lpfnCB As Long) As Long
    >
    > Put the following as a new function:
    > Private Function DownloadFile(UR L As String, LocalFilename As String) _
    > As Boolean
    > Dim lngRetVal As Long
    > lngRetVal = URLDownloadToFi le(0, URL, LocalFilename, 0, 0)
    > If lngRetVal = 0 Then DownloadFile = True
    > End Function
    >
    > Then finally use the following code in your main program:
    > result = DownloadFile("h ttp://intranet/autoid.php", "c:/ai.txt")[/color]
  • Kevin Thorpe

    #2
    Re: Q: Read text with VBA from a PHP web-page

    jabe wrote:
    [color=blue]
    > I created a page on our intranet that shows a number and that
    > increases for every time the page is opened. It is similar to a
    > visitors-counter.
    > When I look at the page with Internet Explorer it works just fine.
    >
    > Now I want to read this web-page from a MS-Word macro and include the
    > number as a company wide unique id in my MS-Word document.
    > Unfortunately, the PHP script doesn't update the counter when I call
    > it from my MS-Word macro.
    >
    > How can I force PHP to update my counter when I call it from a VBA
    > macro?[/color]

    It should do. What do you see in your website logs? Is the downloaded
    file correct? I can only imagine the download isn't working correctly.

    I do similar things from our website using an embedded web browser.
    Various of my VBA (Excel) libraries pop up a dialog box containing an
    embedded browser which offers pages navigating to required content. Once
    the correct page is displayed in the browser my code abstracts the
    contents of the page (usually a table) and imports it into Excel.

    It means that I can have one php script which either displays a table of
    info in a browser, or used from Excel creates a spreadsheet.


    Comment

    Working...