Results 1 to 3 of 3

add a dialogwindow instead

Threaded View

elmnas add a dialogwindow instead 05-29-2015, 09:50 AM
Leith Ross Re: add a dialogwindow instead 05-29-2015, 10:48 PM
elmnas Re: add a dialogwindow instead 06-01-2015, 04:29 AM
  1. #1
    Forum Contributor
    Join Date
    02-23-2015
    Location
    Sweden
    MS-Off Ver
    2013
    Posts
    109

    add a dialogwindow instead

    Hello guys I got this code to modify some XML data,

    I have no hardcoded the filepath,

    Could someone help me to modify my code, add a Dialogwindow so I select a folder then the script loops through all .xml files


    here is my 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
    Last edited by elmnas; 05-29-2015 at 09:53 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Change hardcoded Path to Dialogwindow
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2015, 07:11 AM
  2. need to modify code a bit for dialogwindow
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2015, 08:25 AM
  3. [SOLVED] Need help to modify Variable strDocPath to a Select files (Dialogwindow)
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2015, 12:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1