View Single Post
 
Old 04-17-2017, 12:55 AM
sumshen sumshen is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Apr 2017
Posts: 1
sumshen is on a distinguished road
Default Read multiple xml files in excel - Column names and Tag - Column alignment

Hello All,

I am using the below code to read multiple xml files into a single excel worksheet.
I am looking to do below 2 amends:
  1. Display only the tag names instead of full path as column names.
  2. If one of the xml files has additional tags which contain data, the excel data gets jumbled. I want to align the columns of excel and display blanks in columns if tags are not present. For egs, in attachment, I want to align D7-D11 in Column E.

My Code:

Do While xFile <> ""
Set xmlWb = Workbooks.OpenXML(folderPath & "\" & xFile)
xmlWb.Sheets(1).UsedRange.Copy xlSWb.Sheets(2).Cells(xCount, 1)

Application.DisplayAlerts = False
xmlWb.Saved = True
xmlWb.Close False
Application.DisplayAlerts = True

xCount = xlSWb.Sheets(2).UsedRange.Rows.Count + 1
xFile = Dir()
Loop
Attached Images
File Type: jpg Capture.JPG (88.6 KB, 12 views)
Reply With Quote