Results 1 to 13 of 13

Thread: Combining multiple word documents into one

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    My understanding is that the reason you want to merge the files together is because you were unsuccessful in printing them individually - is this correct? If so, what about setting a delay -


    Dim wordApp As New Word.Application
        Dim myDoc As Word.Document
        Dim myDoc2 As Word.Document     ' DON'T NEED THIS!
        Dim dtmStart As Date
    Const TARGET_FOLDER_ONEPAGE As String = _
            "P:\Clients\Vanguard\Finance\testing\onepagedocs\"
    With wordApp
       .Visible = False
       .ScreenUpdating = False
       .DisplayAlerts = False
       Set Fso = New FileSystemObject
       Set fldr = Fso.GetFolder(TARGET_FOLDER_ONEPAGE)
       For Each f In fldr.Files
          If Right(f.Name, 4) = ".doc" Then
             Set myDoc = Documents.Open(TARGET_FOLDER_ONEPAGE & f.Name)
             ' date/time stamp
             dtmStart = Now()
             myDoc.PrintOut
             myDoc.Merge   ' WHY DO YOU NEED THIS ONE?
             ' set delay here -
             'I've used 2 minutes, may need to experiment
             Do
                DoEvents
             Loop Until DateDiff("n", dtmStart, Now()) > 2
             myDoc.Close False
          End If
       Next f
        End With
    wordApp.Quit
    Last edited by Aussiebear; 04-12-2023 at 06:09 PM. Reason: Adjusted the code tags

Posting Permissions

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