new computer

fastbuck

Board Regular
Joined
Apr 22, 2014
Messages
144
Hi out there. I've just bought a new compute with windows 8 and office 2013. I'm trying to use a spreadsheet with macros that has worked fine on my old computer with office 2007. It comes up with an error that says 'Compile Error. User-defined type not defined' and it highlights this in one of the macros 'xmldoc As MSXML2.DOMDocument''
Can anyone help with this problem - it would be much appreciated.
Thanks
Narelle
 
Try adding the XML reference to the VBA. Inside the VBE, Go to Tools -> References, then Select Microsoft XML, v6.0 (or whatever your latest is. This will give you access to the XML Object Library.) and should fix it.

If not, you might need to post the whole code...
 
Upvote 0
nah that didn't work. Microsoft XML, v6.0 was already selected. I tried v3 but that gave an error as well. Here is the code. it worked great on my last computer with excel 2007. Hope it can be fixed :(
Code:
Sub LoadRaceField()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=""
Dim xmldoc As MSXML2.DOMDocument
Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load ("http://unitab.com/data/racing/" & Format(Range("M4"), "yyyy/m/d") & "/" & Range("M5") & ".xml")
If (xmldoc.parseError.ErrorCode <> 0) Then
MsgBox ("An error has occurred: " & xmldoc.parseError.reason)
Else
Set runnerList = xmldoc.SelectNodes("//Runner")
Sheet3.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
Sheet3.Cells(i + 1, 1) = runnerNumber.Text
End If
If Not runnerName Is Nothing Then
Sheet3.Cells(i + 1, 2) = runnerName.Text
End If
If Not runnerWeight Is Nothing Then
Sheet3.Cells(i + 1, 3) = runnerWeight.Text
End If
If Not riderName Is Nothing Then
Sheet3.Cells(i + 1, 4) = riderName.Text
End If
Set winOdds = runner.SelectSingleNode("WinOdds")
Set placeOdds = runner.SelectSingleNode("PlaceOdds")
If Not winOdds Is Nothing Then
Set winOddsAmount = winOdds.Attributes.getNamedItem("Odds")
If Not winOddsAmount Is Nothing Then
Sheet3.Cells(i + 1, 5) = winOddsAmount.Text
End If
End If
If Not placeOdds Is Nothing Then
Set placeOddsAmount = winOdds.Attributes.getNamedItem("Odds")
If Not placeOddsAmount Is Nothing Then
Sheet3.Cells(i + 1, 6) = placeOddsAmount.Text
End If
End If
Next
End If
Range("E28").Select
ActiveSheet.Protect Password:=""
Application.ScreenUpdating = True

End Sub
 
Upvote 0
If you have the Microsoft XML 6.0 library checked in the project (i.e. actually ticked in the reference list), you should not get that error since MSXML2.DOMDocument is a type in that library. Are any of your checked references listed as 'MISSING:' at the start of their names?
 
Upvote 0
Thanks for your reply. I have the following
Missing MSExchange 1.0 type library
Missing Microsoft outlook 12.0 object library
 
Upvote 0
Start by unchecking both of those. If your code needs to use Outlook, you'll need to add the Outlook 15 library.

What references do you have checked currently?
 
Upvote 0
I took the MISSING one out but it made no difference. Following is what is checked. Many thanks for your help btw.
visual basic for applications
Microsoft excel 15.0 object library
ole automation
Microsoft office 15.0 object library
ctv ole control module
Microsoft xml v6.0
Microsoft html object library
 
Upvote 0
Im still having the same problem. Ive taken a photo of the references box. How do i can i attach it.
 
Upvote 0

Forum statistics

Threads
1,226,812
Messages
6,193,114
Members
453,777
Latest member
Miceal Powell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top