View Single Post
 
Old 04-08-2016, 05:21 AM
JennEx JennEx is offline Windows XP Office 2013
Competent Performer
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Very nice, thank you!

I'm feeling that the actual body content is filling is as desired now, time to move onto the header/footer situation and multi-records per page. I'm not feeling as confident that that will go any smoother.

I found an old archive of a previous attempt to pull off what we've been working on recently. Attached is an older version of the report you have just ironed out for me. It doesn't work because the datasource is messed up, but I managed to get it working enough to see that the header and footer of the merge document carried over and populated on each page of the directory style output document. (mind you the page numbering suffers the same problem)

What is different on this report vs. yours that makes this possible? Here is some of the code that called the merge.

Code:
    Set oDoc = objWord.Documents.Open(Filename:=fName, ConfirmConversions:=True, _
        ReadOnly:=True, AddToRecentFiles:=False, Visible:=False)
    StrSrc = ThisWorkbook.FullName
    With oDoc
        With .MailMerge
            .MainDocumentType = wdDirectory
            .OpenDataSource _
              Name:=StrSrc, ReadOnly:=True, AddToRecentFiles:=False, LinkToSource:=False, _
              Connection:="Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;" & _
                "Data Source=StrSrc;Mode=Read;Extended Properties=""HDR=YES;IMEX=1"";", _
                SQLStatement:="SELECT * FROM `CONTROL_1$` WHERE [Type$]='" & itype & "' AND [SubResp]= '" & isubresp, _
                SQLStatement1:="", SubType:=wdMergeSubTypeAccess
            .Destination = wdSendtToNewDocument
            .SuppressBlankLines = True
            With .DataSource
              .FirstRecord = 1
              .LastRecord = .RecordCount
            End With
            .Execute Pause:=False
            .MainDocumentType = wdNotAMergeDocument
        End With
        .Close False
    End With
Attached Files
File Type: docx DRv978.docx (37.8 KB, 7 views)
Reply With Quote