I've been building a little bot for my business and it is essential that multiple XML files are uploaded at once into Excel to perform the remainder of the bot. I've successfully been able to upload multiple XML's using a loop however, as all the XMLs are not in the same format, it is necessary that only the required information is uploaded into Excel. I've looked up different sources but looks like I am doing it incorrectly. The relevant VBA code I have so far to upload multiple XMLs is this,
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Sheets("Working Notes")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).row
For i = 1 To lastrow
strTargetFile = .Cells(i, "A")
Set Wb = Workbooks.OpenXML(FileName:=strTargetFile, LoadOption:=xlXmlLoadImportToList)
'wb.Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("Working Notes").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
Wb.Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("Working Notes").Range("B" & i)
Wb.Close False
Next i
End With
The XML page I am looking at is this,
<?xml version="1.0" encoding="utf-8"?>
<abcd_omn_gatca:abcd_omn xmlns:abcd="urn:lu:etat:acd:abcd_omn:v2.0" xmlns:ftc="urn:lu:etat:acd:gatca:v2.0" xmlns:sfa="urn:oecd:ties:stfgatcatypes:v2" xmlns:abcd_omn_gatca="urn:lu:etat:acd:abcd_gatca:v2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="urn:lu:etat:acd:abcd_gatca:v2.0 abcd_gatca_V2.0.xsd">
<abcd_omn_gatca:abcd_gatca>
<abcd_omn_gatca:abcd_RefId>XXXXX</abcd_omn_gatca:abcd_RefId>
<abcd_omn_gatca:abcd_Depositor>
<abcd:NameDepositor>XXXXX</abcd:NameDepositor>
<abcd:PersonalIdentificationNumberDepositor>XXXXX</abcd:PersonalIdentificationNumberDepositor>
<abcd:AddressDepositor>
<abcd:StreetPhysical>XXXXX</abcd:StreetPhysical>
<abcd:NumberPhysical>XXXXX</abcd:NumberPhysical>
<abcd:PostalCodePhysical>XXXXX</abcd:PostalCodePhysical>
<abcd:CityPhysical>XXXXX</abcd:CityPhysical>
<abcd:CountryPhysical>XXXXX</abcd:CountryPhysical>
</abcd:AddressDepositor>
<abcd:PersonDepositor>
<abcd:Name>XXXXX</abcd:Name>
<abcd:FirstName>XXXXX</abcd:FirstName>
<abcd:EmailPersonal>XXXXX</abcd:EmailPersonal>
<abcd:TelephoneDirect>XXXXX</abcd:TelephoneDirect>
</abcd:PersonDepositor>
</abcd_omn_gatca:abcd_Depositor>
<abcd_omn_gatca:abcd_Declarer>
<abcd:NameDeclarer>XXXXX</abcd:NameDeclarer>
<abcd:PersonalIdentificationNumberDeclarer>XXXXX</abcd:PersonalIdentificationNumberDeclarer>
<abcd:AddressDeclarer>
<abcd:StreetPhysical>XXXXX</abcd:StreetPhysical>
<abcd:NumberPhysical>XXXXX</abcd:NumberPhysical>
<abcd:PostalCodePhysical>XXXXX</abcd:PostalCodePhysical>
<abcd:CityPhysical>XXXXX</abcd:CityPhysical>
<abcd:CountryPhysical>XXXXX</abcd:CountryPhysical>
</abcd:AddressDeclarer>
<abcd:PersonDeclarer>
<abcd:Name>XXXXX</abcd:Name>
<abcd:FirstName>XXXXX</abcd:FirstName>
<abcd:EmailPersonal>XXXXX</abcd:EmailPersonal>
<abcd:EmailOrganisation>XXXXX</abcd:EmailOrganisation>
<abcd:TelephoneDirect>XXXXX</abcd:TelephoneDirect>
</abcd:PersonDeclarer>
</abcd_omn_gatca:abcd_Declarer>
<abcd_omn_gatca:abcd_ReportingPerson>
***<abcd:NameReportingPerson>RENIN III S.A R.L.</abcd:NameReportingPerson***>
<abcd:IdentificationNumber>XXXXX</abcd:IdentificationNumber>
<abcd:IdentificationNumberExtension>XXXXX</abcd:IdentificationNumberExtension>
<***abcd:AddressReportingPerson>
<abcd:StreetPhysical>Avenue M.F. Brady</abcd:StreetPhysical>
<abcd:NumberPhysical>45</abcd:NumberPhysical>
<abcd:PostalCodePhysical>1234</abcd:PostalCodePhysical>
<abcd:CityPhysical>Somethingburg</abcd:CityPhysical>
<abcd:CountryPhysical>SB</abcd:CountryPhysical>
</abcd:AddressReportingPerson>***
<abcd:PersonContactReportingPerson>
<abcd:Name>XXXXX</abcd:Name>
<abcd:FirstName>XXXXX</abcd:FirstName>
<abcd:EmailPersonal>XXXXX</abcd:EmailPersonal>
<abcd:EmailOrganisation>XXXXX</abcd:EmailOrganisation>
<abcd:TelephoneDirect>XXXXX</abcd:TelephoneDirect>
</abcd:PersonContactReportingPerson>
</abcd_omn_gatca:abcd_ReportingPerson>
<abcd_omn_gatca:RFI_Identifier>XXXXX</abcd_omn_gatca:RFI_Identifier>
<abcd_omn_gatca:ReportContent>
<abcd_omn_gatca:ReportingPeriod>XXXXX</abcd_omn_gatca:ReportingPeriod>
<abcd_omn_gatca:ZeroReporting>XXXXX</abcd_omn_gatca:ZeroReporting>
</abcd_omn_gatca:ReportContent>
</abcd_omn_gatca:abcd_gatca>
</abcd_omn_gatca:abcd_omn>
The only piece of information I require is the name of the reporting person "RENIN III S.A R.L." and the Address of the Reporting Person on the Excel sheet. Forgive me for my very immature knowledge of VBA. I will be much obliged for any help. Many thanks!