Macro in Word 2016 RRS feed

  • Question

  • I have a repeated task in Word 2016 that I wish to automate using a Macro since the document is around 150 pages long each time I have to do this.

    The macro should be able to do this:

    Go down one line.
    Select all text from the start of that line to the end of the first line containing the Word "blokker"
    Delete the selected text.

    The number of lines to be selected varies throughout the document so going down a number of lines will not work.

    Wednesday, June 21, 2017 6:43 AM

All replies

  • Hi Eirran,

    Based on your description, you want to use macro in Word, I will help you move your thread to Word for Developer forum:

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Emi Zhang
    TechNet Community Support

    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact

    Thursday, June 22, 2017 7:56 AM
  • Hi Eirran,

    You could Selection.MoveDown to go down one line and get the start point. Then you could use Selection.Find to find your word and this is your end point. You could confirm a range using a start point and end point. Here is code for example.

    Dim rng1 As Range
    Dim rng2 As Range
    Selection.MoveDown Unit:=wdLine, Count:=1 'down to next line
    Set rng1 = Selection.Range 'starting point
    Selection.Find.Text = SearchStr 'find text
    Set rng2 = Selection.Range 'ending point
    Range(rng1.Start, rng2.End).Delete

    Best Regards,


    Tuesday, June 27, 2017 9:57 AM