Forum


Replies: 7   Views: 4288
Add blank page if odd page count
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by loktron  · 18-11-2016 - 06:46

Can i use dotm files with phpdocx ? Because there is a start ne section allways on uneven page option in word.
 The problem is that, if i activate this in the template, word will add two useless blank pages if the pagecount is even. if it is odd, it works as desired. So my idea was to write a macro in word that counts the pages on save and, if the count is odd, activates this option.

Would that be possible?

Here my Macro:

Sub oddPageNumber(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim count As Integer
    Dim rest As Integer
    
    count = ActiveDocument.ComputeStatistics(wdStatisticPages)
    rest = count Mod 2
    If rest > 0 Then
    Selection.InsertBreak Type:=wdSectionBreakEvenPage
    End If
End Sub