Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2021, 10:52 AM
Ulodesk Ulodesk is offline Stumped Windows 10 Stumped Office 2016
Word 2013 Expert Cert
Stumped
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Stumped

Back again. Not a coder, obviously.



Reviewing some of my macros this morning, I discovered some were not doing what they are supposed to. I have managed to fix a couple but am stumped here.

The first of the following two works fine. The second refuses to stop at the end of whatever selection I make and continues to the end of the document. My test document is attached. For the life of me, non-coder that I am, I cannot see the difference in teh code that would make this happen. Help appreciated.

Code:
Sub ParasDeleteMultiSelection()
'
' Macro6 Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^13{2,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Code:
Sub ParasInsertBlanksSelection()
'
' ParasInsertBlanksSelection Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "[^13]"
        .Replacement.Text = "^p^p"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Attached Files
File Type: docx Test doc.docx (16.0 KB, 9 views)
Reply With Quote
  #2  
Old 12-13-2021, 10:00 PM
gmayor's Avatar
gmayor gmayor is offline Stumped Windows 10 Stumped Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following works
Code:
Sub ParasDeleteMultiSelection()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^13{2,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub ParasInsertBlanksSelection()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "[^13]"
        .Replacement.Text = "^p^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 12-14-2021, 06:06 AM
Ulodesk Ulodesk is offline Stumped Windows 10 Stumped Office 2016
Word 2013 Expert Cert
Stumped
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Thankyou

Thank you, Graham. FindStop instead of FindAsk appears the be the difference. Much obliged. Best wishes for the holidays.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this possible.. I am stumped! gcross4 Excel Programming 0 01-13-2015 03:02 PM
Stumped Stumped by the recorder again Ulodesk Word VBA 6 07-02-2012 09:23 AM
Stumped on Grouping with Custom Fields... ViperMan Project 1 06-22-2011 01:31 AM
Stumped Track chages combine: Stumped! Ulodesk Word 2 01-03-2011 11:43 AM
Stumped With Mail Merge Formula JennEx Mail Merge 0 05-28-2010 07:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:38 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