Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA code to change hyphen to no-break hyphen, Word (97, 2K, XP)

    Greetings,

    Anybody know VBA code to replace a hyphen with a no-break hyphen, and a space with a no-break space in Word 97 and 2K and XP?
    Locating the space and hyphen are no problem, just how to change them to the no-break version.

    Wish I could search your previous answers for this.

    Thanks,
    Jim

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA code to change hyphen to no-break hyphen, Word (97, 2K, XP)

    If you are using the Find object, you can specify a non-breaking space and a non-breaking hyphen exactly the way you would interactively:

    With Selection.Find
    .Text = " "
    .Replacement.Text = "^s"
    ...
    End With

    and

    With Selection.Find
    .Text = "-"
    .Replacement.Text = "^~"
    ...
    End With

  3. #3
    New Lounger
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA code to change hyphen to no-break hyphen, Word (97, 2K, XP)

    Thanks, Hans, I'll give it a try.

    Jim

Posting Permissions

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