Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2020, 08:43 AM
Ulodesk Ulodesk is offline Macro adjustment needed Windows 7 64bit Macro adjustment needed Office 2013
Word 2013 Expert Cert
Macro adjustment needed
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Macro adjustment needed

The following macro replaces single blank paragraphs in a selection with a tab starting the following paragraph, but it tabs any second successive blank line returns rather than removing them, and does not tab the first paragraph selected. Also, it brings up the "would you like to continue searching the document" dialogue, which is unnecessary. I tried toying with the macro, but I don't know what I'm doing, so it didn't work.



I appreciate your help.

Code:
Sub ParasBlankToTabSelection()
'
' Replaces blank paragraphs with a tab starting following paragraph in selected text.
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^13^13"
        .Replacement.Text = "^p^t"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote
  #2  
Old 02-05-2020, 02:51 PM
macropod's Avatar
macropod macropod is offline Macro adjustment needed Windows 7 64bit Macro adjustment needed Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Perhaps:
Code:
Sub ParasBlankToTabSelection()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "^13{2,}"
  .Replacement.Text = "^p^t"
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-06-2020, 06:49 AM
Ulodesk Ulodesk is offline Macro adjustment needed Windows 7 64bit Macro adjustment needed Office 2013
Word 2013 Expert Cert
Macro adjustment needed
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Resolved

Perhaps, indeed, Paul; as always you are the master in these matters. May the sun shine brightly on your day.
Reply With Quote
Reply

Tags
find/replace macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement Adjustment shawn.low@cox.net Mail Merge 0 09-23-2019 10:08 AM
Macro adjustment needed Automatic adjustment date zbiku25 Project 3 02-28-2017 09:03 AM
Macro adjustment needed ***help*** macro needed PokerBob Excel 8 03-18-2015 02:57 PM
Macro adjustment needed Table adjustment on Surface OneNote TheMax OneNote 1 01-23-2015 04:33 PM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM

Other Forums: Access Forums

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