Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2023, 03:44 AM
RobiNew RobiNew is offline Remove extra carriage returns in footnotes Windows 10 Remove extra carriage returns in footnotes Office 2016
Competent Performer
Remove extra carriage returns in footnotes
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Question Remove extra carriage returns in footnotes


Is there a way to remove extra carriage returns in footnotes with a macro? Thanks!
Reply With Quote
  #2  
Old 10-10-2023, 05:11 AM
yanyan9896 yanyan9896 is offline Remove extra carriage returns in footnotes Windows 10 Remove extra carriage returns in footnotes Office 2019
Novice
 
Join Date: Oct 2023
Posts: 13
yanyan9896 is on a distinguished road
Default

Quote:
Originally Posted by RobiNew View Post
Is there a way to remove extra carriage returns in footnotes with a macro? Thanks!

Try this. I found in Lyonizing Word: Deleting Extraneous Carriage Returns in Footnotes and Endnotes | An American Editor



Code:
Sub CleanReturnsInNotes()

NoteCount = ActiveDocument.Footnotes.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find

.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False

End With
Selection.Find.Execute
On Error GoTo TrapTheError
While Selection.Find.Found

Selection.MoveLeft

Selection.Delete
Selection.Find.Execute

Wend
GoTo TheEnd
TrapTheError:

ErrorCount = ErrorCount + 1
Selection.MoveRight
Selection.Delete
If ErrorCount < NoteCount Then Resume Next

TheEnd:
End Sub
Reply With Quote
  #3  
Old 10-10-2023, 06:04 AM
RobiNew RobiNew is offline Remove extra carriage returns in footnotes Windows 10 Remove extra carriage returns in footnotes Office 2016
Competent Performer
Remove extra carriage returns in footnotes
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Many thanks, yanyan9896! I now see that I was wrong in putting the question that way. The macro you posted does remove extra (= empty) carriage returns in footnotes, but what I need is code to remove all carriage returns except, of course, the ending one. Any idea?
Reply With Quote
  #4  
Old 10-10-2023, 07:02 AM
yanyan9896 yanyan9896 is offline Remove extra carriage returns in footnotes Windows 10 Remove extra carriage returns in footnotes Office 2019
Novice
 
Join Date: Oct 2023
Posts: 13
yanyan9896 is on a distinguished road
Default

Quote:
Originally Posted by RobiNew View Post
Many thanks, yanyan9896! I now see that I was wrong in putting the question that way. The macro you posted does remove extra (= empty) carriage returns in footnotes, but what I need is code to remove all carriage returns except, of course, the ending one. Any idea?

Do you mean to remove all carriage returns in the footnote? Or do you mean remove all carriage returns in the whole document?


Do note you don't need a macro for this; it can be done with an ordinary Find/Replace, where:
Find = ^p^p
Replace = ^p


See https://www.msofficeforums.com/word-...e-returns.html
Reply With Quote
  #5  
Old 10-10-2023, 08:16 AM
RobiNew RobiNew is offline Remove extra carriage returns in footnotes Windows 10 Remove extra carriage returns in footnotes Office 2016
Competent Performer
Remove extra carriage returns in footnotes
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

I mean that the macro should remove all carriage returns in the footnotes except, of course, the ending ^p. Thanks!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove extra carriage returns in footnotes replace cell text results in extra carriage return abonsey Word VBA 2 05-27-2022 02:55 AM
Remove extra carriage returns in footnotes Converting table to text (and back) with carriage returns in cells, split and merged cells ndajko Word 5 11-04-2019 07:53 AM
Remove extra carriage returns in footnotes Macro To Delete Specific Carriage Returns NeviZero Word VBA 2 02-09-2018 02:16 PM
Remove extra carriage returns in footnotes Remove Carriage Returns in Address Block Merge field alan100 Mail Merge 5 12-12-2017 08:32 PM
Remove extra carriage returns in footnotes Run Script to remove carriage returns on certain columns ryanjohnsond@gmail.com Excel Programming 34 09-03-2014 10:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft