Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wonder if someone can help me with what i need code wise in the ' HELP here
please below. I want to update EXISTING records from an xml source using the XML data. Details are in the sample code below. Many thanks in advance Sub Read_XML_Data() Dim rst As ADODB.Recordset Dim stCon As String, stFile As String Dim i As Long, j As Long ' This has row records which have the rows "NAME" in Column A ' then updates to other colums within the row ' NB: Only some of the row columns will be updated. stFile = "C:\myupdates.xml" stCon = "Provider=MSPersist;" With rst .CursorLocation = adUseClient .Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile Set .ActiveConnection = Nothing End With With ActiveSheet ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... End With 'Closing the recordset. rst.Close 'Release object from memory. Set rst = Nothing End Sub XML <row <namefred</name <age24</age </row .... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you provide a more complete XML file. the cod eyou provided isn't
opening up the xml file properly. I can get the data into excel if I can get the recordset opened properly. I keep on getting an error that the XML file is incomplete. "Virgil" wrote: I wonder if someone can help me with what i need code wise in the ' HELP here please below. I want to update EXISTING records from an xml source using the XML data. Details are in the sample code below. Many thanks in advance Sub Read_XML_Data() Dim rst As ADODB.Recordset Dim stCon As String, stFile As String Dim i As Long, j As Long ' This has row records which have the rows "NAME" in Column A ' then updates to other colums within the row ' NB: Only some of the row columns will be updated. stFile = "C:\myupdates.xml" stCon = "Provider=MSPersist;" With rst .CursorLocation = adUseClient .Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile Set .ActiveConnection = Nothing End With With ActiveSheet ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... End With 'Closing the recordset. rst.Close 'Release object from memory. Set rst = Nothing End Sub XML <row <namefred</name <age24</age </row ... |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I come clean, i borrowed the XML part from a web sample. I assumed it worked.
here is say 2 rows in xml and i have corrected a syntax error... <?xml version="1.0" ? <row <people <namefred</name <age24</age </people <people <namemary</name <age24</age </people </row Thanks for the interest "Joel" wrote: Can you provide a more complete XML file. the cod eyou provided isn't opening up the xml file properly. I can get the data into excel if I can get the recordset opened properly. I keep on getting an error that the XML file is incomplete. "Virgil" wrote: I wonder if someone can help me with what i need code wise in the ' HELP here please below. I want to update EXISTING records from an xml source using the XML data. Details are in the sample code below. Many thanks in advance Sub Read_XML_Data() Dim rst As ADODB.Recordset Dim stCon As String, stFile As String Dim i As Long, j As Long ' This has row records which have the rows "NAME" in Column A ' then updates to other colums within the row ' NB: Only some of the row columns will be updated. stFile = "C:\myupdates.xml" stCon = "Provider=MSPersist;" With rst .CursorLocation = adUseClient .Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile Set .ActiveConnection = Nothing End With With ActiveSheet ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... End With 'Closing the recordset. rst.Close 'Release object from memory. Set rst = Nothing End Sub XML <row <namefred</name <age24</age </row ... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I still cna't get the RST to open. I had to add new into the following
declaration Dim rst As New ADODB.Recordset Once I get the recordset to open I can easily get the rest of the code to work. "Virgil" wrote: I come clean, i borrowed the XML part from a web sample. I assumed it worked. here is say 2 rows in xml and i have corrected a syntax error... <?xml version="1.0" ? <row <people <namefred</name <age24</age </people <people <namemary</name <age24</age </people </row Thanks for the interest "Joel" wrote: Can you provide a more complete XML file. the cod eyou provided isn't opening up the xml file properly. I can get the data into excel if I can get the recordset opened properly. I keep on getting an error that the XML file is incomplete. "Virgil" wrote: I wonder if someone can help me with what i need code wise in the ' HELP here please below. I want to update EXISTING records from an xml source using the XML data. Details are in the sample code below. Many thanks in advance Sub Read_XML_Data() Dim rst As ADODB.Recordset Dim stCon As String, stFile As String Dim i As Long, j As Long ' This has row records which have the rows "NAME" in Column A ' then updates to other colums within the row ' NB: Only some of the row columns will be updated. stFile = "C:\myupdates.xml" stCon = "Provider=MSPersist;" With rst .CursorLocation = adUseClient .Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile Set .ActiveConnection = Nothing End With With ActiveSheet ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... End With 'Closing the recordset. rst.Close 'Release object from memory. Set rst = Nothing End Sub XML <row <namefred</name <age24</age </row ... |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks for a reply. However my original issue is unresolved ? How to lock the row and update it ? ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... Can you help ? Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can open the XML file in a new worksheet and then extract the information
you are looking for. Right now I can't get the xlm file opened using your methods. If yo uhave a webpage where you obtained you method post it so I can help you solve this problem. "Virgil" wrote: Thanks for a reply. However my original issue is unresolved ? How to lock the row and update it ? ' HELP here please ' Find the row with the same "NAME" as what is in the XML record ' code here 'Copy the data from the XML recordset for this "NAME" into the row '.Range("... rst.... Can you help ? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
import from excel to access with macro? | Excel Programming | |||
Excel Import Macro | Excel Discussion (Misc queries) | |||
Import Macro in PERSONAL.XLS will not import to my main document | Excel Programming | |||
Import Data Excel Macro | Excel Discussion (Misc queries) | |||
Use / Import Win32API in Excel macro | Excel Programming |