Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts

    Multiple documents (Word XP SP1)

    I've got a Word program that generates multiple documents based on selection criteria from a network database.

    Since the individual documents are printed to a network printer, they get intermingled with other documents in the network print que.

    I'd like to combine them at print time into one document for printing.

    All my tired noggin can come up with (in VBA) is to load the first document in Word, got to the end to see if I have to add a page break so that the successive document will start printing on an odd page, load the next document in to Word, select it and paste it to the bottom of the first document. Repeat until I'm out of documents.

    Might there be a simpler VBA method ?

    TIA

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Multiple documents (Word XP SP1)

    Unless all the documents have identical margins, page setup, and styles, slamming them all together could have negative consequences. Anyway, the InsertFile method might do what you want:

    <pre>Option Explicit
    Sub TackOnFile()
    Dim rng As Range
    Set rng = ActiveDocument.Range(ActiveDocument.Content.End - 1, _
    ActiveDocument.Content.End - 1)
    With rng
    .InsertBreak Type:=wdSectionBreakNextPage
    .Collapse direction:=wdCollapseEnd
    ' Maybe you want to try to restart page numbering for this new section
    With .Sections(.Sections.Count).Headers(wdHeaderFooterP rimary).PageNumbers
    .RestartNumberingAtSection = True
    .StartingNumber = 1
    End With
    ' Will the above be nullified by the following?
    .InsertFile FileName:="c:testingextrasavedemo.doc"
    End With
    Set rng = Nothing
    End Sub</pre>

    As an alternative, you could print the documents individually to disk and then queue the files to the printer. But it still probably wouldn't appear to be one print job on the print server's end, so there's still a chance of interruption. Because the files probably end by kicking out the page (or maybe they don't kick out the page), I'm not sure you can use the old [b]copy

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts

    Re: Multiple documents (Word XP SP1)

    Thanks. That's a nice solution and I'll give it a go.

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Multiple documents (Word XP SP1)

    I'll try to implement this in our office too...

    FYI: Part of our job is to process Word documents (as batches of them are sent in shortly before a certain deadline). These documents are evaluation forms from various authors (one for each topic involved) concerning submitted files/cases. Planning and reporting are evaluated seperately. As such, there are some 5000 documents involved (= 10 (7 to 15 topics) * 250 cases * 2 (planning+reporting)). Printing them is one step in the process... Now we use 'traditional' printing, which results in one sheet for each document. As most of them contain less than a page this is quite a waste of paper.

    Still, our printer allows recto verso printing and multiple pages on one side. I'ld like to use these facilities to print several of these Word documents (e.g. each set belonging to a certain file/case) as if they were concatenated in one document. This should be temporarily, as documents need to remain available seperately... (Concerning layout and other related problems, I don't expect too much trouble, as all documents are already based on the same template for uniformity's sake.)

    I have already moreless an Access database (i.e. adapted an example from a forum) in which I (1) load all document info (path & name, to which a naming convention applies, e.g. file_code_year_X.doc with X = P(lanning)/R(eporting)), optionally grouping & sorting them in a specific code order (2) perform an action (like printing, formatting, find-replace (for which it was originally designed),...) on all documents/records selected. It works great. But now concateting sets of documents would be (even more) nice...

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Multiple documents (Word XP SP1)

    It sounds as though you could insert a blank paragraph or two (rather than a section break), skip the page numbering, and use the above code almost "as is." With a bit of tweaking, you probably could automate Word from inside your Access database, since the file names are in there.

  6. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Multiple documents (Word XP SP1)

    Thanks!

Posting Permissions

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