Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word: don't remove a space (2007)

    Hi,

    I have some code that removes bookmarked text:
    Set rRange = oWdDoc.Bookmarks(sBookmarkName).Range
    With rRange
    .Delete Unit:=1, Count:=1
    End With

    If the bookmark is text within a sentence:

    This is some text THIS IS THE BOOKMARK.

    Then the end result becomes:

    This is some text.

    Note that the space preceding the bookmark was removed.

    How can I iether prevent the removal of the space character, or detect if a space before the bookmark was removed?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

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

    Re: Word: don't remove a space (2007)

    It depends on the Smart Cut and Paste option in the Edit tab of Tools | Options. If this option is ticked, Word will "clean up" after removing text; it it isn't ticked, Word will leave the text as it is.
    You could turn off the option temporarily:

    Dim blnSmartCutPaste As Boolean
    blnSmartCutPaste = Options.PasteSmartCutPaste
    Options.PasteSmartCutPaste = False
    ... ' your code here
    ...
    Options.PasteSmartCutPaste = blnSmartCutPaste

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word: don't remove a space (2007)

    I KNEW it had to be a setting like that one, but I just overlooked the darn thing. Thanks.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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