Internet access via DesktopX objects

Microsoft.XmlHttp object

You instantiate this COM object from a script. For instance, say you want to download an html file data you can adapt this code:

'Creates an instance of Microsoft.XmlHttp
Set http = CreateObject("Microsoft.XmlHttp")

'Disables error prompts
On Error Resume Next

'Sets the URL to download
url = "
http.Open "GET", url, False

'Receives data
http.send ""
sWebpage = http.responseText

This is a very simple yet effective way to download data from the internet. Possibly the only limitation is that the method is synchronous, that is, it will block the script execution until the data finished downloading. The interface could hang until the script finished its job. Still, this can be fast and reasonable for most cases.

Please refer MSDN help on how to use XMLHTTP object.

A more complex method of accessing internet data is to use the Microsoft Web Browser.

Microsoft Web Browser control

You can create an hidden MS Web Browser ActiveX control to download internet data. This object is very powerful and can be used for different purposes than the actual html rendering.

Refer MSDN references on this object for information on how to access various html elements, modify the presentation, properties, etc.

As a quick start, create a blank object. Then add a new script. In the menu select "ActiveX control...". Scroll down and select "Microsoft Web Browser".

You can use this simple method to navigate to a page:

Control.navigate2 ""

Select "Event Wizard.." in the script editor menu and add this event:

'Fired when the document being navigated to reaches ReadyState_Complete.
Sub Control_DocumentComplete(pDisp, URL)

End sub

This function is called when the page finished loading. The mechanism is asynchronous, so Object.Navigate2 won't block the script execution flow.

When the document is complete you can use the control methods to access the page data. The simpliest one is:


It will return the whole page content.

Passing URL parameters

When you are passing URL parameters, no matter what method you choose, make sure to correctly escape the text parameters if they can contain special characters.

The VBScript method to do this is:


Design guidelines

Widgets and themes that access the Internet are the most difficult to write properly so they deserve particular attention.
You just can’t assume that a user is connected to the Internet, so browsing could fail and cause very annoying script errors. You should ALWAYS check the connection status, and also check about the success of browsing operations. You should assume that you can retrieve NULL or invalid data.
Also, objects that connect to the Internet should follow a specific usage protocol to avoid annoyances. They should keep an internal connection status that just informs the script about “Can I try to access the Internet? YES/NO”. This is different from the actual connection status, in fact it is more similar to the Internet Explorer Online/Offline status, that’s independent from the actual network connection status.
A tentative protocol works like this: