![]() |
#1
|
|||
|
|||
![]()
I'm doing a text replacement macro that deletes text in one sub, and then has another sub insert different text into the same spot. However, when I delete text and there's a space on either side, Word's default text deletion will eliminate one of the spaces, which means that the inserted text is now lacking a space between it and an adjacent word. It's also messing up formatting when highlighting changes at the same spot.
Original text: Intro <Replace Me> More Sub Test() Dim VarRange As Range SelectText ("<Replace Me>") Set VarRange = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.End) VarRange.Delete Selection.InsertAfter ("New Text") End Sub Should produce: Intro New Text More Actually produces: Intro New TextMore What I'd like is a flag I can set to make it not delete adjacent spaces, but all my searching hasn't shown me one. I know of a couple hacky workarounds that I can use if need be - find-and-replace, in particular - but because of the structure of the code, doing it that way would make the overall program much more complex. Thanks. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I stop check boxes moving rows when text wraps in an adjacent cell? | PatrickYork | Excel | 2 | 04-04-2018 11:23 AM |
Big Spaces/pages between text | tissueboxer | Word | 6 | 03-03-2018 07:52 AM |
Vertical Text Alignment with Adjacent Columns | kdutrisac | Word Tables | 2 | 06-26-2017 12:38 PM |
Deleting grid lines but keeping the axis lines | CoffeeNut | Excel | 0 | 04-01-2013 01:50 PM |
Conditional Formatting Expiration Dates Based on Text in Adjacent Cell | Frogggg | Excel | 1 | 10-25-2011 08:44 PM |