Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel Macro via VBA - XML IMPORT

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
</email
</row
....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel Macro via VBA - XML IMPORT

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
</email
</row
...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel Macro via VBA - XML IMPORT

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
</email
</people
<people
<namemary</name
<age24</age
</email
</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
</email
</row
...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel Macro via VBA - XML IMPORT

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
</email
</people
<people
<namemary</name
<age24</age
</email
</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
</email
</row
...

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel Macro via VBA - XML IMPORT


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel Macro via VBA - XML IMPORT

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
import from excel to access with macro? J.W. Aldridge Excel Programming 2 April 30th 09 09:05 PM
Excel Import Macro gkarasiewicz Excel Discussion (Misc queries) 5 January 12th 08 06:08 PM
Import Macro in PERSONAL.XLS will not import to my main document mike Excel Programming 8 October 31st 07 09:24 PM
Import Data Excel Macro [email protected] Excel Discussion (Misc queries) 3 August 23rd 06 02:11 PM
Use / Import Win32API in Excel macro Ben Zhu Excel Programming 2 September 10th 03 09:37 PM


All times are GMT +1. The time now is 08:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"