none
Microsoft.Office.Interop.Word BookFoldPrinting issue in a document with sections RRS feed

  • Question

  • I can print in booklet format fine when making the changes manually in Word 2016 but it does not work correctly programmatically.

    The document does not print correctly if the

    document.ComputeStatistics(WdStatistic.wdStatisticPages)

    is divisible by 4.

    This does not work on a 4 page document or any document that is divisible by 4

    Section 1 is a Cover Page and a Blank Page

    Section 2 Content with unique Header and Footer with Pages 1-2

    This works on a 9 page document

    Section 1 is a Cover Page and a Blank Page

    Section 2 Content with unique Header and Footer with Pages 1-7

    Any thoughts?  I know I can add a next page - section to end of document if page count is divisible by 4 and it will print correctly but I was wondering if there is something I am missing.

    Thanks!

    • Moved by CoolDadTx Thursday, June 28, 2018 12:35 AM Office related
    Wednesday, June 27, 2018 11:48 PM

All replies

  • Forgot to say I am using C# and Microsoft.Office.Interop and here is the code that changes the settings.

    foreach (Microsoft.Office.Interop.Word.Section sec in document.Sections)
    {
         //changed document.Sections[secCount] to sec
         sec.PageSetup.LineNumbering.Active = 0;
         sec.PageSetup.PaperSize = WdPaperSize.wdPaperLetter;
         sec.PageSetup.PageWidth = winWord.InchesToPoints(11f);
         sec.PageSetup.PageHeight = winWord.InchesToPoints(8.5f);
         if (sec.PageSetup.Orientation != Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape)
         {
              sec.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
         }
         sec.PageSetup.MirrorMargins = 0;
         sec.PageSetup.TwoPagesOnOne = false;
         sec.PageSetup.BookFoldPrinting = true;
         sec.PageSetup.BookFoldRevPrinting = false;
         sec.PageSetup.BookFoldPrintingSheets = 1;
    } // end for each





    • Edited by laaAKer Thursday, June 28, 2018 4:07 PM
    Wednesday, June 27, 2018 11:51 PM
  • Hello laaAker,

    >>This does not work on a 4 page document or any document that is divisible by 4

    What do you mean it does not work? What's the result you want and What's the result you current get?

    I could only see the code how to set PageSetup. Did you print the document programmatically? If so, what's the code you used to print the document.

    By the way, since you are iterating through the section via foreach. I would suggest you use sec object directly instead of document.Section[secCount].

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, June 28, 2018 2:54 AM
  • I am using the Document.Printout() Method and thanks for the suggestion of using the section object directly.  I will make that change.

    Original Document is:

    Title Page - Blank - Content Page 1- Content Page 2 (so a total of 4 pages for the booklet)

    Currently the above code Prints Bookfold as:

    Blank - Blank - Title - Blank - Content Page 1 - Blank - Blank - Content Page 2

    It needs to be:

    Title Page - Blank - Content Page 1 - Content Page 2 (page 2 should be on the back of page 1)

    Now if I manually add a next page section (so it is not divisible by 4) to the end of the document before using the Printout() method it will give me the following (I have added this programmatically): 

    Blank - Blank - Title Page - Blank - Content Page 1- Content Page 2 - Blank - Blank - Blank - Blank - Blank - Blank

    This is okay as the first 2 and last 2 blanks is a blank sheet of pager that can be removed before processing futher:

    Thanks for any ideas or suggestions! 






    • Edited by laaAKer Thursday, June 28, 2018 7:13 PM
    Thursday, June 28, 2018 3:52 PM
  • Hello laaAker,

    What's the version of your office? I tried to do the test in Office 2016 and I failed to reproduce the issue.

    And for avoiding any misunderstanding, I would suggest you share a document for us to test your code. 

    Besides, if you have any other code while printing the document, I also suggest you share them.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 29, 2018 7:30 AM