![]() |
|
|
|
#1
|
|||
|
|||
|
Hi Vivka! I've tested again your code, but space+^p (the last and only ^p) in the footnotes remains intact. The same is true when I try this Find-Replace: "^w^p" ---> "^p" (the first part of your macro).
|
|
#2
|
|||
|
|||
|
RobeNew, I've checked and retested my macro some 7 times without any problem. I'm lost for ideas. The only way out is seeing your file. Maybe there are some things I'm overlooking. Or at least paste here the before & desired outcome footnote strings. I got excited and take it as a challenge. Probably, it's a sort of childish behavior.
|
|
#3
|
|||
|
|||
|
Hi Vivka! Of course I will post an example of my text, but first I'd like to ask you again: since my footnotes do not contain multiple spaces, but only one space before the only ^p at the end, couldn't you simply modify the code here below so as to delete the space instead of inserting it? Thanks!
Code:
Sub InsertSpace() Dim aRng As Range Dim iType As Integer Dim Para As Paragraph For iType = 1 To 2 Set aRng = ActiveDocument.StoryRanges(iType) For Each Para In aRng.Paragraphs Para.Range.Characters.Last.InsertBefore " " Next Para Next iType Set aRng = Nothing End Sub |
|
#4
|
|||
|
|||
|
Hi, RobiNew! It's quite simple:
replace: Para.range.Characters.Last.InsertBefore " " with: Para.range.Characters.Last.Previous.Delete But this method deletes any (not anly space!) before the para sign and it is not the fastest one. To delete only spaces, the following condition should be included, which also will make the code a millisecond slower: If Para.range.Characters.Last.Previous = " " Then Para.range.Characters.Last.Previous.Delete End If RobiNew, I really can't understand why the code from post 9 doesn't work for you! I have retested it this morning again - and no problem! I'm eager to see your footnote! |
|
#5
|
|||
|
|||
|
Hi Vivka! Thank you for your patience. I'm attaching a test file with footnotes.
|
|
#6
|
|||
|
|||
|
Hi, RobiNew! This is a workaround to delete spaces ending paragraphs only in footnotes but it is the fastest method:
Code:
Sub Footnotes_Spaces_Del()
'In the doc's footnotes, delete spaces ending paragraphs.
Dim oRng As range
Application.ScreenUpdating = False
Set oRng = ActiveDocument.StoryRanges(2)
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
'Find one space and an invisible paragraph sign:
.text = " ^p"
'Add an extra space (or more in case there are extra spaces elsewhere in footnotes)
'before a paragraph end (note that the para sign is absent here!):
.Replacement.text = " "
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
With oRng.Find
'Find more than one space (in case of error, replace ; with comma):
.text = Chr(32) & "{2;}"
'Delete them:
.Replacement.text = ""
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
Set oRng = Nothing
End Sub
on several footnotes on the same page. This is the reason for my misunderstanding. If you want to include the main text in the macro, add this just after ScreenUpdating = False line: With ActiveDocument.range.Find .ClearFormatting .Replacement.ClearFormatting .text = "^w^p" .Replacement.text = "^p" .MatchWildcards = False .Execute Replace:=wdReplaceAll End With |
|
#7
|
|||
|
|||
|
Hi Vivka! Sorry, but your code does not work on automatic footnotes. The reason for this is that it is again based on a replacement action which is not allowed (even if ^p is absent in the .Replacement.text). If it were possible to replace footnote ending paragraphs, then any user could destroy the footnotes by mistake. If you try a Find&Replace action of the type ^p ---> "" (or ---> ^l) on any text with multiple paragraphs you will get a single paragraph. If you could do that in the automatic footnotes area you would get a single footnote out of a whole series of footnotes.
|
|
#8
|
|||
|
|||
|
Hi Vivka! The code here below produces an error. Can you help? Thanks!
Code:
Sub EliminaSpazio()
'Text and Footnotes: Removes space before paragraph mark
'Qui per poi eliminare tutti i paragrafi vuoti.
Dim aRng As Range
Dim iType As Integer
Dim Para As Paragraph
For iType = 1 To 2
Set aRng = ActiveDocument.StoryRanges(iType)
For Each Para In aRng.Paragraphs
If Para.Range.Characters.Last.Previous = " " Then 'ERROR
Para.Range.Characters.Last.Previous.Delete
End If
Next Para
Next iType
Set aRng = Nothing
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to remove gap between text and footnotes on Mac?
|
gemmajackson7 | Word | 1 | 05-16-2021 07:26 AM |
How to Remove trailing spaces AND line breaks in a block of text
|
JulianS96 | Word | 4 | 02-04-2020 04:20 AM |
Remove Paragraph / Spaces
|
sharina1985 | Mail Merge | 1 | 10-05-2019 03:52 AM |
| big spaces appearing automatically in certain parts of the text - how to remove them | pratodifuoco | Word | 2 | 05-26-2017 12:55 PM |
| editing text and remove spaces | romanticbiro | Word VBA | 5 | 07-04-2014 07:42 PM |