View Single Post
 
Old 04-05-2016, 07:37 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you want a Directory merge, change:
.MainDocumentType = wdFormLetters
to:
.MainDocumentType = wdDirectory
Do note, however, that means you'll lose your individual page headers & footers - a Directory merge can have only one of each. An alternative would be to perform a Letter merge (as per the current code), then delete the Section breaks post-merge. The outcome will be the same, though. You can do that by inserting the following code after .DisplayAlerts = True
Code:
        With .ActiveDocument
          If .Sections.Count > 1 Then
            For Each HdFt In .Sections(.Sections.Count).Headers
              If HdFt.Exists Then
                HdFt.Range.FormattedText = .Sections(1).Headers(HdFt.Index).Range.FormattedText
                HdFt.Range.Characters.Last.Delete
              End If
            Next
            For Each HdFt In .Sections(.Sections.Count).Footers
              If HdFt.Exists Then
                HdFt.Range.FormattedText = .Sections(1).Footers(HdFt.Index).Range.FormattedText
                HdFt.Range.Characters.Last.Delete
              End If
            Next
          End If
          Do While .Sections.Count > 1
            .Sections(1).Range.Characters.Last.Delete
            DoEvents
          Loop
          .Range.Characters.Last.Delete
        End With
As for the AM/PM, I'm not having any trouble here. See attached.

The generation of duplicate reports suggests your code is being called twice.
Attached Files
File Type: docx DR15v1.docx (380.4 KB, 14 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote