![]() |
#1
|
|||
|
|||
![]()
Hi All
I'm trying to insert hard spaces into some text in a Word Document. This would mean that after running the code on the selected text , Hello There! would become H e l l o T h e r e ! including a double space between the words. Can someone advise with some code , please? Grateful for any help. Last edited by Chayes; 07-02-2018 at 10:50 AM. Reason: add additional text |
#2
|
||||
|
||||
![]()
You don't need a macro for that - a simple Find/Replace will do the job, where:
Find = ^? Replace = ^&^32 or: Find = ^? Replace = ^&^160 the latter will help keep words together.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Depending on why you wish to add such spacing you might also consider the font spacing which might be easier to manage in the long term.
e.g. Try increasing the font spacing to 5 pt for a section of text. This gives the appearance of adding spaces between characters. |
#4
|
||||
|
||||
![]()
It also has the advantage of not unnecessarily breaking words for line-wrapping purposes.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Hi
Ok thanks for this. I find Find = ^? Replace = ^&^32 works fine. It inserts a hard space between each letter in a word , which is exactly what I was looking for. Curiously , where a space exists say between two words in a phrase , it makes this into 3 spaces rather than the expected 2. Easily remedied with another search / replace , but I thought you'd like to know. Thanks for your help - much appreciated. |
#6
|
||||
|
||||
![]()
The Find/Replace inserts a space after every character - including spaces. So, if you replace a letter followed by a space with those characters and spaces, you'll end up with a letter followed by three spaces.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
Yes , I can see how that works. As I was saying , It's relatively easily remedied with another search/replace , but it's a pity it can't be done on first application. At any rate , thanks again for your help.
![]() |
#8
|
||||
|
||||
![]()
You could use a wildcard Find/Replace, where:
Find = [! ] Replace = ^&^32
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]()
Yes , that's got it. Perfect first time. Many thanks for your help.
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
aditya_bokade | Word VBA | 28 | 11-13-2021 10:48 PM |
![]() |
DavidL | Word VBA | 7 | 04-04-2018 12:01 AM |
Detecting that previous character doesn't exist (i.e., present character is first in document) | Robert K S | Word VBA | 15 | 08-01-2016 09:33 AM |
![]() |
redzan | Word VBA | 3 | 05-22-2014 04:22 PM |
Office 2010 - insert character after each line. | Ernst-Emil | Word | 7 | 08-15-2012 09:13 AM |