Connect Mathcad to Internet Data Sources

One little-known feature of Mathcad 15 (and earlier versions) is the ability to connect to Internet data sources. Simply insert a scriptable component into a worksheet, define an input and an output, and insert this VBScript into the component code.

Function IEGetPage(URL)
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Navigate URL
  Do While IE.Busy
  IEGetPage = IE.Document.Body.outerText
 End Function

IEGetPage(URL) is a function that downloads the data the URL points to.

This function can be used to define the output of the scriptable component. For example, you could insert the following code into a push button event (PushBtnEvent_Exec)

Outputs(0).value = IEGetPage(Inputs(0).Value)

Outputs(0).value and Inputs(0).Value refer to the first input and output of the scriptable component. In this instance, the input would simply be a URL and the output would be the downloaded data.

So what can I do with this surprisingly cool functionality? Well, the US Geological Survey host constantly updated earthquake data on their website. This data gives the location (i.e. the latitude and longitude) and magnitude of earthquakes over a rolling time period, and can be downloaded as a text file. is a typical example.

This text file is updated several times a day with new earthquake data and can be downloaded straight into Mathcad using the VBScript given above.  Check out this Mathcad worksheet (the link is at the bottom of this post).

Once the data the data is in Mathcad, some parsing is needed to strip out headers and other unnecessary information.  You can then manipulate and analyse the filtered data.

In the Mathcad worksheet, I’ve plotted the location of earthquakes on a map of North America (the mapping data is low resolution, but it serves its purpose). Here’s what the plot looks like:

My next mini-project (should I get some time off from the salt mines) is to project this earthquake data onto a globe.

I’ve also connected Mathcad to other Internet data sources, including historical stock quotes and foreign exchange rates.

Mathcad Worksheet to Download Earthquake Data from the US Geological Survey Website

What do our Customers say about us?

Excellent – a natural teacher! Approachable and willing to help us individually

PD, Manchester, UK

The new Quick Fit Gadget is fantastic and I absolutely love that I can output results to a worksheet so that I can get a column of a particular parameter on which I can do statistical analysis.

Greg Scott, University of Illinois at Urbana-Champaign

I am very grateful for your prompt and kind answers to my problems. It is rarely a pleasure to complain about something, but this time it has been both pleasant and helpful. I can only regret that I did not use Swedish with Linda, men vi kan s

HV, Helsinki, Finland

At 13-years old, my daughter’s research manuscript has been accepted for publication in a top tier peer-reviewed Environmental Science journal and OriginPro 8.6 will allow her to export the graphs in a wide variety of formats which can meet any publisher’s requirements. Kudos to OriginLab for designing innovative and intuitive software that can span the needs of both a burgeoning young scientist like my daughter to a PhD expert in their field. It is hard to imagine that other products offer this extraordinary level of user versatility.

Michael Grimmett, MD, FACP, FACS Ophthalmologist Palm Beach Gardens, Florida

For the time being we are unable to offer the following product ranges although we are currently working hard to increase the number of products we can offer in the future. Please contact us to talk about alternative products that we may be able to offer you.