By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,983 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,983 IT Pros & Developers. It's quick & easy.

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

P: n/a
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:
Put the following into the Declarations section of your program:
Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(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(URL As String, LocalFilename As String) _
As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(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("http://intranet/autoid.php", "c:/ai.txt")

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jabe wrote:
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?


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.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.