Results 1 to 2 of 2

Thread: [RESOLVED] Batch process instead of hardcoded

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    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.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width