creat columns of text inside xml files in excell

Dpalkon

New Member
Joined
Dec 4, 2019
Messages
9
Office Version
  1. 365
Platform
  1. Windows
I need to make a simple modification to a couple thousand .xml files that are used as recipes for a machine I have. I've done this in the past with .dat files that were just text using a vbscript that created a colum for each file that started with the file name and then each row had the text that was on each line. this worked great but the .dat files only had 10 rows of text without symbols OR anything crazy. I'm trying to do the same thing with the .xml files I have but they have a lot of extra text that is not being transfered to the excel file. I'll post the vbscript that works well for the .dat file and also an example of the xml file I need to get into excell.
This is what is inside the xml file and I just need to change one of the values (spin speed) on thousands of files. What I've done in the past is converted many text files to rows inside of excel, made modifications to the data and then convertd them back to text files ending in .dat. This was amazing and worked really well. However that same script doesn't work for this .xml file. Well it actually worKs but I only get the name not the valves below the name. I can post the script I'm using as well and perhaps someone can help me get this done. the script that works for simple .dat files is below the sample .xml text.

I really only need a script that will pull out the numbers between ,<value>X</Value> I need the X's in a column that I can modify. Then I'll need to take that modified data and create a .xml file that looks like the file below with the new data.

thanks,

Dave

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="recipe.xsl"?>
<TAGLIST>
<TAG>
<NAME>hmi_Spin_at_Dip</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Hopper_Lower</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Cycle</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Dip</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Numb_Dump</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Batch_Weight</NAME>
<VALUE>150</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Speed</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Speed</NAME>
<VALUE>300</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Time</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Time</NAME>
<VALUE>15</VALUE>
</TAG>
<TAG>
<NAME>hmi_Number_of_Spins</NAME>
<VALUE>2</VALUE>
</TAG>
<TAG>
<NAME>hmi_InVibe_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Conveyor_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Customer_Name</NAME>
<VALUE>slidematic</VALUE>
</TAG>
<TAG>
<NAME>hmi_Part_Description</NAME>
<VALUE>m8x1.25x56mm</VALUE>
</TAG>
<TAG>
<NAME>Recipe_Top_Coat_Type</NAME>
<VALUE>black tnt-15</VALUE>
</TAG>
</TAGLIST>
*************************SCRIPT THAT WORKS GREAT FOR CONVERTING .DAT FILES TO COLUMNS WITHIN AN EXCEL SHEET*********

Sub import_text_files()
Dim sh As Worksheet, wPath As String, wFile As String
Dim w2 As Workbook, sh2 As Worksheet, k As Long, lr2 As Long

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Set sh = Sheets("Sheet1")
sh.Cells.Clear
k = 1

With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Selecciona una carpeta"
.AllowMultiSelect = False
.InitialFileName = ThisWorkbook.Path
If .Show <> -1 Then Exit Sub
wPath = .SelectedItems(1)
wFile = Dir(wPath & "\" & "*.dat")
Do While wFile <> ""
Set w2 = Workbooks.Open(wPath & "\" & wFile)
Set sh2 = w2.Sheets(1)
lr2 = sh2.Range("A" & Rows.Count).End(xlUp).Row
sh.Cells(1, k).Value = wFile
sh.Cells(2, k).Resize(lr2).Value = sh2.Range("A1:A" & lr2).Value
k = k + 1
w2.Close False
wFile = Dir()
Loop
End With
MsgBox "End"
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top