Results 1 to 8 of 8

Thread: VBA to relocate XML blocks

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    I don't know what I'm doing, something like:
    Sub test()
    For Each cll In Range("A2:A300").Cells
      blah2 "C:\XML_Source_Files\" & cll.Value, "C:\output\" & cll.Value
    Next cll
    End Sub
    
    Sub blah2(myFullPathAndNameSource, myFullPathAndNameDestn)
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    xx = FSO.OpenTextFile(myFullPathAndNameSource).ReadAll    'your source file
    pos1 = InStr(xx, "<referencedApplicGroup>")
    pos2 = InStr(xx, "</referencedApplicGroup>")
    newxx = Left(xx, pos1 - 1) & Mid(xx, pos2 + 24)
    insertText = Mid(xx, pos1, pos2 - pos1 + 24)
    pos3 = InStr(newxx, "<content>")
    newxxx = Left(newxx, pos3 - 1) & insertText & Mid(newxx, pos3)
    Set txtstr = FSO.CreateTextFile(myFullPathAndNameDestn, True, True)    'your destination file.
    txtstr.Write newxxx
    txtstr.Close
    End Sub
    Run test
    Last edited by p45cal; 04-23-2019 at 06:10 PM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

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
  •