Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 06-02-2021, 09:46 PM
macropod's Avatar
macropod macropod is offline Help with a logical code, end of paragraph lines Windows 10 Help with a logical code, end of paragraph lines Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I don't know what 'TST_End_of_Sentence_' is about, but it seems to suggest you're running some sort of loop. Your code is also slow because of its heavy use of Selection.

With the Find/Replace operation I suggested, there'd be no looping through the content. All you'd use is:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "([\(«]*>)^32"
    .Replacement.Text = "\1^s"
    .Forward = True
    .Format = False
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
You also have some strange-looking Find/Replace operations. For example:
.Text = "(*>)^32(A-Z)"
.Replacement.Text = "\1^s\2"
would replace an ordinary space before any upper-case letter with a non-breaking space. Why would you do that?

Similarly,
.Text = "([%$])"
.Replacement.Text = "^s\1"
would insert a non-breaking space before % or $, even if there's already a space there, with the potential of ending up with both a space (which may or not be a non-breaking space) followed by non-breaking space.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
help end of sentence, long paragraphs



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a logical code, end of paragraph lines How to change the line spacing between just 2 lines within a paragraph Swarup Word 4 06-26-2019 02:32 PM
How to get rid of horizontal lines after each paragraph? Nisus Word 10 10-08-2018 01:15 PM
double spaced within paragraph 2 blank lines between paragraphs BigOldArt Word 1 08-24-2017 09:08 AM
Help with a logical code, end of paragraph lines Lines refuse to merge into one paragraph (Word 2010) Chris24 Word 2 01-22-2017 03:00 PM
Help with a logical code, end of paragraph lines Keep Paragraph Lines Together Issue SQLUSA Word 2 06-23-2012 05:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:28 PM.


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