+ Post New Thread
Results 1 to 12 of 12
MIS Systems Thread, Printing XML Files in Batch in Technical; We have all our reports stored on a network drive that have been created by SIMS, but they are in ...
  1. #1

    Join Date
    Jul 2010
    Posts
    20
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Printing XML Files in Batch

    We have all our reports stored on a network drive that have been created by SIMS, but they are in XML format.

    If we want to print 30 of them in one go (all from one folder) the only solution I have is to do file > open in word 2007 and then click tools and print (once the files are selected)

    This seems to print them in a really random order and I want them to be alphabetical when they come off the printer.

    Any suggestions?

    Mike

  2. #2

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,956
    Thank Post
    774
    Thanked 1,487 Times in 1,234 Posts
    Rep Power
    367
    I used to have a vbs script that printed a whole folder of files, it would invoke the application and print, but i don't think that works anymore.

    I still have 2 scripts for renaming the files which is all you need to do in order to fool the system into letting you print them. 1 to rename a folder of .xml files to .doc and the other to undo the process.

    It's best to undo, otherwise you could run in to issues with programs on other computers not liking the file type or security programs warning of the contents not being of the right type.

    Have a go and see if it works. You need to provide the full path to the folder where the files live.

    There was also a way to hack the registry on XP and add a print option to the right click context menu, but i never found the notes for that. This lets you do the same, once you've renamed.

    Attached Files Attached Files

  3. #3

    Join Date
    Jul 2010
    Posts
    20
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Well, the problem actually being that when I select them all in the word file open dialog and use the tools>print option, it does them in a really random order.

    I can batch print them all, but really need them to come out of the printer in alphabetical order (which I'd assumed they would as the filenames were listed alphabetically....

    Thanks for your reply, though.

  4. #4

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,956
    Thank Post
    774
    Thanked 1,487 Times in 1,234 Posts
    Rep Power
    367
    If you batch print from a folder they come out in order. Using the right click print method. Well they print down the list starting from the one you clicked on. So if you start at the top...

    EDIT: more specifically though, for your issue, is the dialog box in Detail view? I think it would matter and you'd want the top file to be active when you choose print.

    I've never batch printed straight from Word, the folder method was easier for us.
    Last edited by vikpaw; 14th October 2010 at 04:26 PM. Reason: addition

  5. #5
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,540
    Thank Post
    112
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    41
    maybe a script to rename the files would be more useful...?

  6. #6
    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
    I have a macro that merges all the files into one document and I then print it from there. I do it this way for mass editing and checking. I have another one that inserts a page between them all as well (usually a key to grades etc). If you are interested I will post it up. I am sure there is an older version on here already as well.

  7. #7
    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
    Quote Originally Posted by browolf View Post
    maybe a script to rename the files would be more useful...?
    This can be an annoyance sometime. I use a bulk renaming tool with a few regular expressions to sort this. Typical situation is it outputs everything with the teachers initials first and I want them to be grouped in subjects, so I get the subject name to the front and the initials to the end.

  8. #8

    Join Date
    Jul 2010
    Posts
    20
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by ChrisH View Post
    I have a macro that merges all the files into one document and I then print it from there. I do it this way for mass editing and checking. I have another one that inserts a page between them all as well (usually a key to grades etc). If you are interested I will post it up. I am sure there is an older version on here already as well.
    Chris, I would be very interested to give this a go, could you email it to me at mike.ruddell@whsb.essex.sch.uk?

    Thanks

  9. #9

    Join Date
    Dec 2009
    Posts
    59
    Thank Post
    2
    Thanked 8 Times in 6 Posts
    Rep Power
    15
    Sounds really odd Mike. I've used the approach you are trying without issue for the last couple of years, countless times, and provided when you browse to select the files to print, they are being displayed in alphabetical sort order in the Windows browser, there surely shouldn't be anything to prevent that being the way they are worked through, should it? I simply drag to select all files in a folder, and if they are generated reports from SIMS named in the conventional way with Surname-Forename-etc-etc, they are normally displayed in Surname sort order and print exactly the same way.

    Does the same thing happen for a random group of Word documents saved as .xml that haven't been created from SIMS?

  10. #10

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,956
    Thank Post
    774
    Thanked 1,487 Times in 1,234 Posts
    Rep Power
    367
    @chrish; - please post the scripts for both file merge and the interleave option, i'm sure i can find a use for it.

  11. #11
    newpersn's Avatar
    Join Date
    Nov 2010
    Location
    Gloucestershire
    Posts
    1,424
    Thank Post
    340
    Thanked 130 Times in 94 Posts
    Rep Power
    92
    didnt work. but i hope its just a setting on the file to do with permissions. Will test again later on.

    Sorry to dig an old post up.

  12. #12
    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
    Sorry I seemed to miss the replies to this:

    This first one does the merge and puts a sheet on the back. It saves it one level up from the folder the files reside in and calls it the folder name plus whatever you put at the end of this line:

    Code:
    strFileLocation = strLocations(X) + " Form Tutor Copy"
    In my case I have all the folders named the same as the class/form.

    The following line is where you define the back page:

    Code:
     rng.InsertFile "Z:\Assesment\Letter Head\YR7 First Interim Report Key.doc"
    It could do with a little cleaning up with some constants etc but it works.
    It can add the odd blank page so you just quickly go through and delete them.
    I run this on Office 2003 at the moment because when I run it on Office 2007 it puts double spacing on all the table and text for some reason.

    Code:
    Sub MergeAllDocsWithKey()
        Dim rng As Range
        Dim headerDoc As Document
        Dim MainDoc As Document
        Dim TempDoc As Document
        Dim strFile As String
        Dim sec As Section
        Dim strLocations(6) As String
        Dim strFileLocation As String
        Dim PageCounter As Integer
        
        Dim X As Integer
        PageCounter = 1
        strLocations(1) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\A"
        strLocations(2) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\C"
        strLocations(3) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\F"
        strLocations(4) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\M"
        strLocations(5) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\S"
        strLocations(6) = "X:\SIMS Reports\2010-2011\YR7 IPDC\Autumn Term\W"
      
    
        For X = 1 To UBound(strLocations)
        strFileLocation = ""
        strFolder = strLocations(X) + "\" 'change to suit
        Set MainDoc = Documents.Add
        strFile = Dir$(strFolder & "*.xml")
        Do Until strFile = ""
        ' Go to the end of the DOC
            Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            If rng.End > 0 Then
                'rng.InsertBreak wdSectionBreakNextPage
                ' Go to the end of the DOC
                Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            End If
            
            'Insert the Interim Report
            rng.InsertFile strFolder & strFile
            'Get Next file
            strFile = Dir$()
            ' Go to the end of the DOC
            Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            rng.InsertBreak wdSectionBreakNextPage
            rng.InsertFile "Z:\Assesment\Letter Head\YR7 First Interim Report Key.doc"
            ' Go to the end of the DOC
            Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            ' Insert Page break
            Set rng = MainDoc.Bookmarks("\EndOfDoc").Range
            PageCounter = PageCounter + 1
        Loop
        strFileLocation = strLocations(X) + " Form Tutor Copy"
        ' ColourSubjectCells
        ActiveDocument.SaveAs FileName:=strFileLocation, FileFormat:=wdFormatDocument
        ActiveDocument.Close SaveChanges:=False
        Next X
    End Sub
    If you don't want the back page then you just comment out a few lines.



SHARE:
+ Post New Thread

Similar Threads

  1. Need help with batch files please!
    By richrad_mills in forum Windows
    Replies: 13
    Last Post: 23rd June 2010, 08:24 PM
  2. Rename a batch of files all at once.
    By Kyle in forum How do you do....it?
    Replies: 10
    Last Post: 19th November 2009, 07:31 AM
  3. Help parsing XML files using VB
    By SimpleSi in forum Coding
    Replies: 5
    Last Post: 10th June 2009, 09:25 AM
  4. Search replace across multiple XML files
    By ajbritton in forum Windows
    Replies: 6
    Last Post: 7th April 2008, 12:07 AM
  5. numbers and batch files
    By russdev in forum Windows
    Replies: 4
    Last Post: 19th November 2005, 10:51 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
  •