![]() |
|
#1
|
||||
|
||||
![]()
OK - all you need to do is change two pieces in the code:
First you need to add in the symbol for a paragraph marker - this will mean that the code will then ONLY replace the spaces AFTER a paragrph marker, second alter the 'replace' field to indicate a paragraph marker (see the red indicators below!) (Use the 'Show/Hide' button to see the ¶ symbol) Code:
Sub Find_and_replace_spaces_Macro() ' Macro re-written 6/25/2009 by Bird_FAT ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^p " .Replacement.Text = "^p" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Do While Selection.Find.Execute With Selection If .Find.Forward = True Then .Collapse Direction:=wdCollapseStart Else .Collapse Direction:=wdCollapseEnd End If .Find.Execute Replace:=wdReplaceOne If .Find.Forward = True Then .Collapse Direction:=wdCollapseEnd Else .Collapse Direction:=wdCollapseStart End If .Find.Execute End With Selection.MoveLeft Unit:=wdCharacter, Count:=1 Loop End Sub |
#2
|
|||
|
|||
![]()
I have added ^p before "PROTOCOLLO" and before "DISTINTI SALUTI" at the begging row. Then I have execudet your code like your post but the result was:
RUN TIME ERROR "5624" Degub error: Do While Selection.Find.Execute I think i don't understand correctly your istructions. |
#3
|
||||
|
||||
![]()
Have you tried copying and pasting my code - as it is written in my last post? I tried it on your files, it worked fine for me!
|
#4
|
|||
|
|||
![]()
Ok now it works perfectly!!!!!
Many many many many thanks!!!!!!!!!!!!!!!!!!!!!!! |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
geobruin | Word | 1 | 06-12-2009 06:55 AM |
Spaces After Each Word | jnutella | Word | 0 | 03-04-2009 02:00 PM |
![]() |
George99 | Word | 1 | 12-06-2008 09:59 AM |
Word to Excel hyperlinks and spaces | gak | Word | 1 | 09-14-2008 08:38 AM |
protected form with underline fillable spaces | rohitsahib | Word | 0 | 02-02-2006 10:22 AM |