Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2017, 05:25 PM
JennEx JennEx is offline Significant Blank Space At Top Of Page When Records Merged 1 Per Page Windows XP Significant Blank Space At Top Of Page When Records Merged 1 Per Page Office 2013
Competent Performer
Significant Blank Space At Top Of Page When Records Merged 1 Per Page
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

It still doesn't look good Paul. I did add the extra field as you suggested, although I'm unsure if maybe I missed an important step " change back to a directory/catalog merge". I can admit to not knowing how to intentionally do this. I only have this problem with this report.



And I'm stumped as to why I am unable to get the 'Page of Pages' fields to not do anything in any report. There doesn't appear to be anything complicated about them. My other merge fields work in the footer. I don't even think I can blame the data for this. And it works for you.
Reply With Quote
  #2  
Old 04-30-2017, 07:14 PM
macropod's Avatar
macropod macropod is offline Significant Blank Space At Top Of Page When Records Merged 1 Per Page Windows 7 64bit Significant Blank Space At Top Of Page When Records Merged 1 Per Page Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
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

Quote:
Originally Posted by JennEx View Post
I did add the extra field as you suggested, although I'm unsure if maybe I missed an important step " change back to a directory/catalog merge". I can admit to not knowing how to intentionally do this.
You'd only do either of those things if you did both! And, as I said:
Quote:
The downside to that, of course, is that you then can't have mergefields in the header/footer.
Try the attached. I've reviewed & revised some of your field coding. You will need to reconnect to your own data source.
Attached Files
File Type: docx DT15v1.docx (430.6 KB, 9 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-01-2017, 10:30 AM
JennEx JennEx is offline Significant Blank Space At Top Of Page When Records Merged 1 Per Page Windows XP Significant Blank Space At Top Of Page When Records Merged 1 Per Page Office 2013
Competent Performer
Significant Blank Space At Top Of Page When Records Merged 1 Per Page
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Thanks Paul,

When I apply my datasource to your revised version of my report ... I have no more blank pages and the Page of Pages fields populate. But, the times are all decimals. This report was a result of merging directly from Word.

Feel free to have a look at this document by downloading it from here.

Interestingly, when I execute this merge by way of my Excel VBA application, I get different results. I get multiple records per page but the Page of Pages does populate. This document can be downloaded here.

I am leaning towards Excel being the problem? As I look closer at the code, I do see reference to page breaks....

For what it's worth, here is the code from Excel that is applying the merge ...

Code:
Sub merge2(ByVal i As Long, ByVal rpt_od As String, objWord As Object, ByVal dest As Long)

    Dim oDoc As Object, oDoc2 As Object
    Dim StrSQL As String, fName As String, StrSrc As String, strFilename As String, myPath As String
    Dim qfile As String, st_srchfn As String, wb_qfile2 As Workbook, itype As String, isubresp As String
    'Dim wb_qfile2 As Workbook
    Dim HdFt As Variant
    
    Const wdSendtToNewDocument = 0
    Const wdSendToPrinter = 1
    Const wdFormLetters = 0
    Const wdDirectory = 3
    Const wdMergeSubTypeAccess = 1
    Const wdOpenFormatAuto = 0
    
    work_fn = ws_vh.Range("N2")
    Set wb_nwb = Workbooks(work_fn)
    
    'create workorders folder
    myPath = "u:\PWS\Parks\Parks Operations\Sports\Sports17\WORKORDERS\" & Format(ws_vh.Range("B17"), "ddd dd-mmm-yy")
    If Dir(myPath, vbDirectory) = "" Then 'if not already created ...
        MkDir myPath
    End If
    
    'close data file
    st_srchfn = "u:\PWS\Parks\Parks Operations\Sports\Sports17\DATA\" & ws_vh.Range("N2")
    If wb_nwb Is Nothing Then
        MsgBox wb_nwb & " is NOT open."
    Else
        wb_nwb.Close True 'saves data workbook after TYPE was updated for GS
    End If
  
    itype = Right(ws_th.Range("A" & i), 2)
    isubresp = Left(ws_th.Range("A" & i), 3)
    
    If itype = "DR" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\DR15v1.docx"
    ElseIf itype = "DT" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\DT15v1.docx"
    ElseIf itype = "FR" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\FR15v1.docx"
    ElseIf itype = "FT" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\FT15v1.docx"
    ElseIf itype = "CR" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\CR15v1.docx"
    ElseIf itype = "CT" Then
        fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\CT15v1.docx"
    ElseIf itype = "GS" Then
        If isubresp = "HPE" Or isubresp = "HPL" Then
            fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\GS15v1_GSH.docx" 'Passive : Hillside
        Else
            fName = "u:\PWS\Parks\Parks Operations\Sports\Sports17\REPORTS\v1\GS15v1_GS.docx" 'Passive : Wloo Park
        End If
    Else
        fName = "U:\PWS\Parks\Parks Operations\Sports\Sports15\REPORTS\v1\GS15v1_GM.docx"
    End If
    
    StrSrc = "u:\PWS\Parks\Parks Operations\Sports\Sports17\DATA\" & ws_vh.Range("N2")
 
    StrSQL = "SELECT * FROM [DATA$] WHERE [TYPE]='" & itype & "' AND [SIG_CREW]='" & isubresp & "' " & _
        "ORDER BY [STARTS] ASC, [COMPLEX] ASC, [UNIT] ASC"
 
    Set objWord = CreateObject("Word.Application")
    With objWord
        .DisplayAlerts = False
        .Visible = True
        Set oDoc = .Documents.Open(Filename:=fName, ConfirmConversions:=False, _
            ReadOnly:=True, AddToRecentFiles:=False, Visible:=True)
        With oDoc
            With .MailMerge
                .MainDocumentType = wdFormLetters
                .Destination = wdSendtToNewDocument
                .SuppressBlankLines = True
                .OpenDataSource Name:=StrSrc, AddToRecentFiles:=False, LinkToSource:=False, ConfirmConversions:=False, _
                    ReadOnly:=True, Format:=wdOpenFormatAuto, Connection:="Provider=Microsoft.ACE.OLEDB.12.0;" & _
                    "User ID=Admin;Data Source=" & StrSrc & ";Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";", _
                    SQLStatement:=StrSQL, SQLStatement1:="", SubType:=wdMergeSubTypeAccess
                .Execute Pause:=False
            End With
            .Close False
        End With
        .DisplayAlerts = True
        
        'page break routine only for sports reports
        If Left(itype, 1) <> "G" Then   'exclude GS reports
            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
        End If
    
    End With
    
    Set oDoc2 = objWord.activedocument

    'save newly created document
    With oDoc2
        myPath = "u:\PWS\Parks\Parks Operations\Sports\Sports17\WORKORDERS\" & Format(ws_vh.Range("B17"), "ddd dd-mmm-yy")
        .SaveAs myPath & "\" & rpt_od & ".docx"
        If dest = 2 Then
            .PrintOut
        End If
        '.Close
    End With
        

    Set oDoc = Nothing: Set oDoc2 = Nothing ': Set objWord = Nothing

End Sub
Hopefully having posted external links to my files are OK. I do need to maintain control over their access, and this is the only way I can see doing it.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Significant Blank Space At Top Of Page When Records Merged 1 Per Page Blank space at top of page Vecchia Word 4 12-26-2014 07:44 AM
Significant Blank Space At Top Of Page When Records Merged 1 Per Page Removing space before blank page / page break greasel Word 5 10-17-2014 07:04 PM
Insert page break vs blank page harvey4 Word 2 08-20-2014 07:15 PM
Multiple records on the same page Hugh Mail Merge 2 04-04-2014 05:24 PM
Significant Blank Space At Top Of Page When Records Merged 1 Per Page First section will not 'insert' blank page even though sectn 2 is 'odd' page break Pat_Hodgson Word 6 12-01-2013 04:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft