View Single Post
  #24  
Old 4th August 2015, 03:33 PM
walkermac walkermac is offline
Member
 
Join Date: Nov 2013
Posts: 603
Default

Quote:
Originally Posted by Puntz
Just a quick question walkermac,
It's obvious to see now, soon Excel VBA's days are numbered in the area of web query, ( dynamic ) unless MS does what the phantoms and the pythons do, and I doubt it.

So do you see it happening, where there may be many "band-aid" type scriptings to full on scripting to compensate the ever changing web page structures, where once Excel VBA was able to do with a simple Record Macro and now it's becoming more and more not able to ?

I ask this cos the past few weeks on the other thread about the bet sender project, it became obvious this is the way we ( punters/non programmers but savvy types) may have to accept, an adaption to change or compliment VBA.

First, I don't want to paint myself an expert, as the recent thread you referred to was what spurred my learning and led me to these tools. I agree that Excel isn't likely to implement this as they have Web Querys. As close as it's probably going to get is a third party module like Selenium (http://florentbr.github.io/SeleniumBasic). According to their blurb, you can record macros using user actions in a browser (like you can record macros in Excel presently).
Code:
How to create/record a VBA script ? •Launch Firefox and Selenium IDE (Ctrl+Alt+S) •Open or record a script •Click on Menu "Option>Format>VBA", select the Tab "Source" and copy the text •Or Click on Menu "File>Export Test Case As>VBA" and save the file •Paste the generated script in a module in Excel VBA (Alt + F11) How to run a VBA script in Excel with Visual Basic for Application ? •Open a new workbook or the provided template (All Programs/SeleniumWrapper/Excel Template) •Click on Menu "Tools>Macro>Visual Basic Editor" •Add the reference "SeleniumWraper Type Library" in Tools>References (Already present in the template) •In VBE, click on menu "Insert>Module" and paste your code •Click on Run in VBE or Run the macro from Excel

It supports PhantomJS, but I'm not sure how you'd interract with a headless browser. ...maybe you record the macro using a regular browser and then just change the VBA code to use the PhantomJS instead of Firefox. That is, in the auto-generated code, just change:
Code:
driver.start "firefox", "http://news.yahoo.com"

to
Code:
driver.start "phantomjs", "http://news.yahoo.com"

Though you can't see the actual data in the HTML code (when you View Source in a regular browser) they still have a named placeholder for it. *shrug* I'm not sure... There's some documentation on Selenium here: https://code.google.com/p/selenium-vba/.
Reply With Quote