Control the Firefox Browser from VBA Macro in Excel
Hello, I need a command that I can use in Excel VBA that works the same way as the "ReadyState" web control in IE, which is to load a URL (which I do through Application.SendKeys) and then Wait until the page is loaded before moving to the next step of the macro, rather than using a time delay, as this macro will be run on different systems with different network speeds. This is for the Firefox browser.
N.B. I have tried all the Excel forums I can find, so now I will try the Mozilla Firefox ones! :)
Can anyone help?
All Replies (3)
Mozilla does not offer a COM interface to automate Firefox. Possibly there is a third party product. ??
Are you loading a page that you control? In that case, you could add a script to change the document's <title> when the page is ready, and Firefox should then update the window caption.
VBA can use the Windows methods FindWindow and GetWindowText to read the titles of open windows so you could detect the change. If you poll for it for some period of time, you should find it.
Third party software is possible like Selenium for example, but the thing is I want to be able to distribute my macro as an intuitive 'click and go' Excel application, without people having to install extensions etc. so that option is a no go.
Basically I am loading a few pages throughout the macro, performing a list of user defined searches, and retrieving the URLs from those pages, (youtube search, and load video, and grab URL for example) so I need to be sure that in all systems, regardless of network speed, the macro waits until the page is ready, otherwise it will continue with the next step before it should which will cause it to fall over. A time delay is a workaround I am currently implementing, but it can add a lot of unnecessary time to the macro's execution when trying to cater for all speeds of network, especially when the macro is asked to run 200+ times which is entirely possible.
I like your idea of changing the document's name when the page is but I don't control the page unfortunately no, so it won't be an option.
Thanks for your suggestion, aby more welcome!
Why use Firefox? I realize what I'm about to say is Windows-centric, but why not use use the controls Microsoft gives you??