ChrisH Posted December 16, 2008 Posted December 16, 2008 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
sahmeepee Posted December 16, 2008 Posted December 16, 2008 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 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.
ChrisH Posted December 16, 2008 Author Posted December 16, 2008 Thanks for the info. I found a macro that seems to fit the bill. If it works I will post it.
ChrisH Posted December 16, 2008 Author Posted December 16, 2008 It works I cant take credit I got it of EE. 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now