I have requirement to export excel spreadsheet data to XML. To do this i added few lines of code in WorkSheet_Activate i.e.,
Private Sub Worksheet_Activate()
Dim oMyconnection As Connection
Dim oMyrecordset As Recordset
Dim oMyXML As DOMDocument
Dim oMyWorkbook As String
Set oMyconnection = New Connection
Set oMyrecordset = New Recordset
Set oMyXML = New DOMDocument
oMyWorkbook = Application.ThisWorkbook.FullName
oMyconnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & oMyWorkbook & ";" & _
"Extended Properties=excel 8.0;" & _
"Persist Security Info=False"
oMyrecordset.Open "Select * from [Sheet1$A1:C100]", oMyconnection, adOpenStatic
oMyrecordset.Save oMyXML, adPersistXML
oMyXML.Save (ThisWorkbook.Path & "\Output.xml")
oMyrecordset.Close
Set oMyconnection = Nothing
Set oMyrecordset = Nothing
Set oMyXML = Nothing
But when ever i try to execute it i am getting an error like User-Defined Datatype not found. Actually i am getting this error because of the line Dim oMyXML As DOMDocument. Am i missing any reference? Any help would be appreciated greatly.
Microsoft ActiveX Data Objects 2.5 Library. but getting same error. I am using Excel2010.Microsoft ActiveX Data Objects 2.5 Library, and when i try to addDAO 3.6reference it giving me an error like error in loading dll.