with dialogwindow instead of hardcoded

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Hello guys I have made following code

Could someone help me instead of hardcoded path's & filename
I would like to have a dialogwindow,
the loop open all xml files where I set the location, then loop through them and then save with the original name.
here is my code see below:


Code:
Sub xmlAddValues()


Dim analyse
Dim exactContexts
Dim subnode
Dim repeated
Dim realRepeated
Dim tmpValue


Set analyse = CreateObject("Msxml2.DOMDocument.6.0")
analyse.Load "C:\test\example.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:\test\Example.xml" ' HERE IS HARDCODED
End Sub

Thank you in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Application.GetOpenFilename is the simplest method, and there is also Application.FileDialog(msoFileDialogFilePicker).
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

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