none
Word, remove incorrects columns break RRS feed

  • Question

  • I have a function in c# that reads a word document by words. First it is placed on the page and then it goes through the words. The words are between columns.
    On some pages, by mistake there is a column jump that causes me when requesting the next word, to return the one from the next column. However, the rest of the correct words below the jump of the column are shown on the screen.
    I can not remove the wrong codes by hand because they are many pages and also the screen display gets out of control.
     
    I need to delete that code by software and the execution will return the next word of the same column without the columns getting out of control. I know by software what the wrong codes are by controlling their vertical position.
     
    Word loop on the page:
    foreach (Microsoft.Office.Interop.Word.Range word in MyRange.Words)
     
    Vertical 
    vertical float = word.get_Information (Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage);
     
    Incorrect Column Break:
    if (word.text == "\ u000e" && vertical <650)
    ...
     
    Thanks for your help.
    Thursday, November 16, 2017 4:50 PM

All replies

  • Hi zequion,

    What's your current issue?

    Since you could catch the incorrect column break, you could just deleted the incorrect column break and then continue to loop until catch the correct column break.

                    if (word.Text == "\u000e" && vertical < 650)
                    {                  
                        word.Delete();
                    }
                    else if (word.Text == "\u000e" && vertical >= 650) {
                        return;
                    }
                    Debug.Print(word.Text);

    Best Regards,

    Terry


    MSDN Community Support Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; 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, November 17, 2017 8:13 AM