<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Root>
<EmployeeInfo>
<Name>Jane Winston</Name>
<Date>2001-01-01</Date>
<EMPCODE>0001</EMPCODE>
</EmployeeInfo>
<ExpenseItem>
<Date>2001-01-01</Date>
<Description>Airfare</Description>
<Amount>500.34</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-01</Date>
<Description>Hotel</Description>
<Amount>200</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-01</Date>
<Description>Taxi Fare</Description>
<Amount>100.00</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-01</Date>
<Description>Long Distance Phone Charges</Description>
<Amount>57.89</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-01</Date>
<Description>Food</Description>
<Amount>82.19</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-02</Date>
<Description>Food</Description>
<Amount>17.89</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-02</Date>
<Description>Personal Items</Description>
<Amount>32.54</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-03</Date>
<Description>Taxi Fare</Description>
<Amount>75.00</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-03</Date>
<Description>Food</Description>
<Amount>36.45</Amount>
</ExpenseItem>
<ExpenseItem>
<Date>2001-01-03</Date>
<Description>New Suit</Description>
<Amount>750.00</Amount>
</ExpenseItem>
</Root>
Sub Import_Xml()
Dim arrFiles, bAppend As Boolean, XMLFilePath
arrFiles = Application.GetOpenFilename("XML files,*.xml", , "Upload New xml", , True)
If Not IsArray(arrFiles) Then MsgBox "No file selected. Process will be canceled.": Exit Sub
bAppend = MsgBox("Add to existing LIST (YES). Create new list (NO)", vbYesNo) = vbYes
With ActiveWorkbook.XmlMaps("Root_Map")
For Each XMLFilePath In arrFiles
MsgBox ("Sheet: " & XMLFilePath)
.Import XMLFilePath, bAppend
bAppend = False
Next
'.DataBinding.Refresh
End With
End Sub
To place them on one sheet, you will need a call to another subroutine, that counts the cell rows, and places the latest upload on the cellcount PLUS ONE!
FUNCTION COUNTROWS (whatsheet)
Countrows=cells(thisworkbook.worksheets (whatsheet).rows.count, 1).end (xlup).row
End FUNCTION
now to use it, you set it up like this in your loop:
Startrow=COUNTROWS("thesheetnameyouwanttocount")
NOW, you have a variable of Startrow that cooresponds with the last line entry. Make certain you increment the Startrow variable by one afyer it returns the count as to not rewrite the last cell, with the first kine of the newest upload. And rememeber, youmust count the rows in each iteration of the loop.
Append = MsgBox("Add to existing LIST (YES). Create new list (NO)", vbYesNo) = vbYes
which offer for me add information from the scratch or continue adding to already existing.
The issue here now, is that no matter what i chose ( it is working) and no matter how many files i am adding, the last file is added twice, and if selected 1 file the data from the file as well entered twice. if i will not gonna find the reason :) i will just add the line which will delete the last row, as it is duplicated.