+ Post New Thread
Results 1 to 4 of 4
Office Software Thread, Merging multiple word (.xml) documents [SOLVED] in Technical; I am exporting individual reports from assesment manager but I need them all in one document so I can run ...
  1. #1
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,007
    Thank Post
    124
    Thanked 286 Times in 263 Posts
    Rep Power
    109

    Merging multiple word (.xml) documents [SOLVED]

    I am exporting individual reports from assesment manager but I need them all in one document so I can run some extra macros on them.
    Basically I have a folder full of word (.xml) files and I need them all merging into one document so I can apply some macros to them. I am not applying the macros to the template because I cant find the right way to run them as SIMs just spits them straight out as documents. I have googled a few solutions but they dont seem to work.
    Any help greatly appreciated.

    ChrisH

  2. #2
    sahmeepee's Avatar
    Join Date
    Oct 2005
    Location
    Greater Manchester
    Posts
    795
    Thank Post
    20
    Thanked 70 Times in 42 Posts
    Rep Power
    34
    I don't have any SIMS-generated xml files to play with at the moment, but you may be able to find a common xml element which always contains the "meat" of the report. When I just made a test xml file in Word 2003, the <w:body> tag contained all the goodies.

    Presumably it's not impossible to write a regular expression to extract just those bits of the files, concatenate them all together and then stick all the extraneous Word xml guff at the top and bottom. You might need to do some voodoo if you want to maintain a page break between them or somehow get them apart again after your tweaks.

  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,007
    Thank Post
    124
    Thanked 286 Times in 263 Posts
    Rep Power
    109
    Thanks for the info. I found a macro that seems to fit the bill. If it works I will post it.

  4. #4
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,007
    Thank Post
    124
    Thanked 286 Times in 263 Posts
    Rep Power
    109
    It works I cant take credit I got it of EE.


    Code:
    Sub MergeDocs()
        Dim rng As Range
        Dim MainDoc As Document
        Dim strFile As String
        Dim sec As Section
        Const strFolder = "C:\reports\"
        Set MainDoc = Documents.Add
        strFile = Dir$(strFolder & "*.xml")
        Do Until strFile = ""
            Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            If rng.End > 0 Then
                rng.InsertBreak wdSectionBreakNextPage
                Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            End If
            rng.InsertFile strFolder & strFile
            strFile = Dir$()
        Loop
    End Sub



SHARE:
+ Post New Thread

Similar Threads

  1. Moodle - Word template to create Moodle XML Quiz
    By lasercat in forum Virtual Learning Platforms
    Replies: 4
    Last Post: 25th October 2010, 01:19 PM
  2. Search replace across multiple XML files
    By ajbritton in forum Windows
    Replies: 6
    Last Post: 7th April 2008, 12:07 AM
  3. Open Office documents & Word 2003
    By Kyle in forum Office Software
    Replies: 8
    Last Post: 24th January 2008, 05:23 PM
  4. How do you turn Zoom show multiple pages off? (MS word)
    By Pottsey in forum How do you do....it?
    Replies: 0
    Last Post: 7th December 2007, 02:57 PM

Thread Information

Users Browsing this Thread

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

Posting Permissions

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