#16
|
|||
|
|||
Quote:
I couldn’t know how to eliminate spaces between words such that “National spatial plan of zone one” Will look like: “Nationalspatialplanofzoneone” What should I include in the code below to eliminate spaces between words? .Text = "[,.;:‘’'“”""/\!\#\*\†\?\\] Best Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#17
|
||||
|
||||
Unless you want to have to manually select every occurrence of 'National spatial plan of zone one', you should use an ordinary Find/Replace, with:
Find = National spatial plan of zone one Replace = NationalSpatialPlanOfZoneOne or: Find = National spatial plan of zone one Replace = Nationalspatialplanofzoneone
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
Quote:
Is there any code to this? It is very frequent that I need to eliminate spaces between selected words in different cases! Is there such code that eliminates spaces between selected words?
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#19
|
||||
|
||||
It ia not proctical to use a macro - it would have no advantage over Ctrl-H to access the Find/Replace dialogue. As I said before, you would need to input the exact Find/replace strings. Sure, you can tell Word to find spaces and delete them, but it will delete all spaces in the selection/document - hardly the kind of thing I would want to trust to a macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#20
|
|||
|
|||
Quote:
Best Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#21
|
||||
|
||||
It's not really a question of whether you can do it with a macro. The real issue is that you can't do it without knowing what the starting text is. While it is possible to do the conversions with a macro, using a selection as a starting point (thus providing the starting text), why are you not entering the text as you want it to appear? To me, it seems rather silly for someone to type 'National spatial plan of zone one' or 'national spatial plan of zone one' when what is really wanted is 'NationalSpatialPlanOfZoneOne'.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#22
|
|||
|
|||
Quote:
Let me just give an example, It is very frequent that I receive lisp files for the AutoCAD. Then the issue here is to better manage these lisp files. 1. I ensure that the spelling that describes what each lisp file does is correct. In this case, I’m obliged to type them word by word with space! 2. As names with spaces are rejected in the AutoCAD lisp files (code), then I’m forced to eliminate them. To better distinguish these words, I aimed at letting the first word to be capital This is the kind of workflow I’m encountered in! the words are: Turn on thaw unlock visible annotation then Turn On Thaw Unlock Visible Annotation then TurnOnThawUnlockVisibleAnnotation 3. And as I got so many lisp files then it is difficult to manage such very frequent kind of work manually 4. What is wrong with the Word just to eliminate spaces between words by a code (for particular selected words)? Screenshots are attached Best Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#23
|
||||
|
||||
Hi Jamal,
The 'normal' approach in such a situation is to replace the spaces with underscores. That way, it remains readable but also works with software that can't handle spaces.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#24
|
|||
|
|||
Quote:
And then again we need such code that can replace the spaces with underscores!
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#25
|
||||
|
||||
Try:
Code:
Sub SpaceToUnderscore() Application.ScreenUpdating = False Dim StrFnd As String, StrRep As String With Selection.Range StrFnd = Trim(.Text) .Case = wdTitleWord StrRep = Replace(Trim(.Text), " ", "_") End With With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = StrFnd .Replacement.Text = StrRep .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#26
|
|||
|
|||
Quote:
I couldn’t imagine this forum without your distinct help and efforts. Words can't describe how thankful I am Best Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Track chages combine: Stumped! | Ulodesk | Word | 2 | 01-03-2011 11:43 AM |
Combine two forms into one | lwisniewski | Word VBA | 3 | 12-24-2010 03:45 PM |
Combine pst files? | markg2 | Outlook | 2 | 04-26-2010 03:09 PM |
How do you combine two contact folders? | waikoloavrm | Outlook | 0 | 04-12-2010 02:31 PM |
Bulletizing one paragraph affects all paragraphs | GoodWebby | Word | 0 | 10-10-2009 12:09 PM |