Results 1 to 16 of 16

Thread: How do I insert a blank line before bold text in a selection?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Regular
    Joined
    Jan 2018
    Posts
    34
    Location
    Quote Originally Posted by Aussiebear View Post
    @Helen269. You were asked what is the logic that determines when to insert the extra space. Your response is weird at best. We don't need to know how you arrived at your "solution' but rather the method of determining when you need a space included.
    Sorry, I misunderstood.

    And maybe it's because I've slept on it or the coffee I just had, but I found some code that I edited slightly to do what I need. The only trouble is it continues past the selection to the end of the doc:

    Sub LineBeforeBold()
        With Selection.Find
            'Set search criteria for bold font
            .Font.Bold = True
            'Find next occurrence
            .Execute
    'Each time bold text is found add a line break before it then find the next one
            Do While .Found
                Selection.Text = vbCrLf + Selection.Text
                .Execute
            Loop
    End With
    End sub
    I now just need to figure out how to make it work only on a selection and then stop and not do the rest of the doc. I've tried inserting
    .Wrap = wdFindStop

    at various points, but that doesn't work. Something to do with Range, maybe...?
    Last edited by Aussiebear; 06-24-2022 at 02:24 PM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •