none
Word-VB.NET- Apply style to trimmed paragraphs

    Question

  • Hi,

        When a particular range is selected, I want to trim both leading and trailing spaces of all the paragraphs in the selection and apply a particular style to all the paragraphs. The only way I could do this is to iterate through all paragraphs, changing the selection object each time.

    This takes a considerable amount of time if the initial selection spans across many paragraphs.

    Is there an efficient way to do this?

    Thanks,

    Nandu

    Sunday, March 19, 2017 5:43 AM

Answers

  • Thanks Cherry.

    I did a work-around to achieve this. The idea is to edit the Selection's Text by removing all spaces around a paragraph break. I was able to do this using Regex. This approach will not take much time even if the selection contains many paragraphs.

    Cheers

    Nandu

    • Marked as answer by Nandu_V Wednesday, March 29, 2017 5:48 AM
    Wednesday, March 29, 2017 4:43 AM

All replies

  • Hi Nandu_v,

    According to my search, I don't find another efficient way to trim both leading and trailing spaces of all the paragraphs in the selection and apply a particular style to all the paragraphs.

    Best regards,

    Cherry Bu


    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.

    Wednesday, March 22, 2017 5:15 AM
    Moderator
  • Thanks Cherry.

    I did a work-around to achieve this. The idea is to edit the Selection's Text by removing all spaces around a paragraph break. I was able to do this using Regex. This approach will not take much time even if the selection contains many paragraphs.

    Cheers

    Nandu

    • Marked as answer by Nandu_V Wednesday, March 29, 2017 5:48 AM
    Wednesday, March 29, 2017 4:43 AM
  • Hi Nandu_V,

    Glad to hear this issue has been solved by yourself. Thanks for your sharing, I will introduce this experience to other forum users who face the same condition. Please mark your reply to close this case.

    Best regards,

    Cherry Bu


    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.

    Wednesday, March 29, 2017 5:09 AM
    Moderator