Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 821325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:37:19+00:00 2026-05-15T02:37:19+00:00

I am creating a MS Word document entirely through C# in VS 2008. I

  • 0

I am creating a MS Word document entirely through C# in VS 2008. I am trying to insert a page break, and when the page break is inserted, instead of inserting it and adding a new page at the bottom, it is inserting a break and adding a page at the top. This results in the first page being the last page.

Here is the code for inserting the page break:

                start = 0;
                end = 0;
                Word.Range rngDoc = Range(ref start, ref end);
                rngDoc.Collapse(ref CollapseEnd);
                rngDoc.InsertBreak(ref pageBreak);
                rngDoc.Collapse(ref CollapseEnd);

Also, each page is consumed by a table, if this helps with the diagnostics

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:37:20+00:00Added an answer on May 15, 2026 at 2:37 am

    InsertBreak never inserts after the selection. Note the MSDN remarks:

    When you insert a page or column break, the selection is replaced by the break. If you don’t want to replace the selection, use the Collapse method before using the InsertBreak method. When you insert a section break, the break is inserted immediately preceding the Selection object.

    (My emphasis.) To get a break at the end of the page, I think you’ll have to select nothing (as you are here) at the end of the document.

    I can’t recall whether the Document has its own range. Can you just get an all-encompassing range from myDoc.Characters?

    If not, the first thing I would try is

    start = int.MaxValue;
    end = int.MaxValue;
    

    If that doesn’t work, you might resort to ComputeStatistics(). Something like this:

    WdStatistic stats = WdStatistic.wdStatisticCharacters;
    var chars = myDoc.ComputeStatistics(stats, false);
    

    And then create your range from that value. Wish I could help more, but it’s been a while for me. Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple word doc, using the openXml SDK. It is working
I am looking at the feasibility of creating something using C# and iTextSharp that
I am creating a simple game designed to prompt the user for the Greek
I created and deployed a WCF client (launched from a VSTO Word Addin) on
I have been perusing the internet in search of the best way to accomplish
I have more of a 'problem solving' question than a syntax related problem. Briefly,
I'm working on a script for importing component information for SketchUp. A very helpful
Iceland :Country\nEurope::Continent\nReykjavik:City with the above string, i would like to match words that appear
I've discovered its impossible to modify the line height in a UILabel. Bummer. Also
I use Spring IoC in my stand-alone Java application. When the application starts it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.