|
The following is a step-by-step example on how to import basic race field data in to Excel 2003.
1) Create a new spreadsheet in Excel.
2) Open the "Visual Basic Editor" by pressing ALT+F11, or selecting from the menus Tools > Macro > Visual Basic Editor.
[See Screenshot]
3) The "Visual Basic Editor" should open as a new window. In this new window open the references window by selecting from the menus Tools > References...
4) This should open a window with a long list of options. Scroll down this list until you find the options starting with "Microsoft XML". Click on the checkbox next to the option with the highest versions ('v') number, making sure it is checked, and then press "OK".
[See Screenshot]
5) Create a new macro named 'LoadRaceField' by selecting from the menus Tools > Macros, entering 'LoadRaceField' in to the "Macro Name" field, and pressing "Create".
[See Screenshot]
6) Put the following code inside the newly created macro:
Sub LoadRaceField() Dim xmldoc As MSXML2.DOMDocument Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False xmldoc.Load ("http://tatts.com/pagedata/racing/2010/6/28/VR6.xml") If (xmldoc.parseError.errorCode <> 0) Then MsgBox ("An error has occurred: " & xmldoc.parseError.reason) Else Set runnerList = xmldoc.selectNodes("//Runner") Sheet1.Cells.Clear For i = 0 To (runnerList.Length - 1) Set runner = runnerList.Item(i) Set runnerNumber = runner.Attributes.getNamedItem("RunnerNo") Set runnerName = runner.Attributes.getNamedItem("RunnerName") Set runnerWeight = runner.Attributes.getNamedItem("Weight") Set riderName = runner.Attributes.getNamedItem("Rider") If Not runnerNumber Is Nothing Then Sheet1.Cells(i + 1, 1) = runnerNumber.Text End If If Not runnerName Is Nothing Then Sheet1.Cells(i + 1, 2) = runnerName.Text End If If Not runnerWeight Is Nothing Then Sheet1.Cells(i + 1, 3) = runnerWeight.Text End If If Not riderName Is Nothing Then Sheet1.Cells(i + 1, 4) = riderName.Text End If Next End If End Sub
[See Screenshot]
7) Save your work and close the "Visual Basic Editor" window, returning to your main spreadsheet.
8) On "Sheet1" of your spreadsheet, open the "Forms" toolbar by selecting from the menus View > Toolbars > Forms
[See Screenshot]
9) This should pop-up a tool bar with various options on it. Hover over them until you find the "Button" option. When you click this option, your cursor should change, and you should be able to 'draw' a button on to your spreadsheet. When you finish drawing your button, a window should appear with a list of macros to assign to the button. The 'LoadRaceField' macro should be in the list.
10) Double click on the 'LoadRaceField' option, and close (or move out of your way) the "Forms" toolbar.
[See Screenshot]
11) Save your work.
12) Click on the button you added to your spreadsheet, and with any luck the basic race field data for VR6 on the 28th of June, 2010 should load in to your spreadsheet.
[See Screenshot]
|