[RESOLVED] Batch process instead of hardcoded
have made this code in VB I am totally a beginner.
If you see I have an absolute path also absolute filename. then when the script its done its save to an absolute path and filename.
I would like instead, You press on a button from the button you select a folder the script loops through the whole folder after "xml" files. then save with same name.
See code
Code:
Dim analyse
Dim exactContexts
Dim subnode
Dim repeated
Dim realRepeated
Dim tmpValue
Set analyse = CreateObject("Msxml2.DOMDocument.6.0")
analyse.Load "C:\00_Projekte_temp\analyse.xml" 'HERE IS HARDCODED
Set exactContexts = analyse.SelectNodes("//inContextExact")
For i = 0 To exactContexts.Length - 1
Set subnode = exactContexts(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
att.Value = "0"
Exit For
End If
Next att
Next i
Set repeated = analyse.SelectNodes("//crossFileRepeated")
For i = 0 To repeated.Length - 1
Set subnode = repeated(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
tmpValue = att.Value
att.Value = "0"
Exit For
End If
Next att
Set realRepeated = subnode.NextSibling
For Each att In realRepeated.Attributes
If att.Name = "words" Then
att.Value = Val(att.Value) + Val(tmpValue)
Exit For
End If
Next att
Next i
analyse.Save "C:\00_Projekte_temp\analyse2.xml" 'HERE IS HARDCODED
Could someone help me to modify the code ?
Thank you in advance.
Re: Batch process instead of hardcoded
You can use a FolderBrowserDialog to allow the user to select a folder path. There are plenty of examples about. You can likewise use a SaveFileDialog to allow the user to select a target file path.