Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2025, 11:26 AM
nonno nonno is offline Add en-dash as the beginning of every paragraph Windows 11 Add en-dash as the beginning of every paragraph Office 2021
Novice
Add en-dash as the beginning of every paragraph
 
Join Date: Mar 2023
Posts: 13
nonno is on a distinguished road
Default Add en-dash as the beginning of every paragraph

I have some macros that are update the paragraph style, but now need a macro that can place an en-dash at the beginning of every paragraph.
Reply With Quote
  #2  
Old 02-22-2025, 12:38 PM
Italophile Italophile is offline Add en-dash as the beginning of every paragraph Windows 11 Add en-dash as the beginning of every paragraph Office 2021
Expert
 
Join Date: Mar 2022
Posts: 555
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

No need for VBA, you can do that with Find. Find paragraph marks and replace with a paragraph followed by an en-dash.
Reply With Quote
  #3  
Old 02-22-2025, 02:49 PM
nonno nonno is offline Add en-dash as the beginning of every paragraph Windows 11 Add en-dash as the beginning of every paragraph Office 2021
Novice
Add en-dash as the beginning of every paragraph
 
Join Date: Mar 2023
Posts: 13
nonno is on a distinguished road
Default

As I mentioned, I'm going to incorporate this with other macros, so it would be nice to do this with a macro as well.

I recorded a macro and updated it to get this, but it skips the very first paragraph of the Word document.

Code:
Sub Macro9()
    
    Selection.HomeKey Unit:=wdStory, Extend:=wdMove
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "^p"
        .Replacement.Text = "^p ^= "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote
  #4  
Old 02-22-2025, 03:25 PM
macropod's Avatar
macropod macropod is offline Add en-dash as the beginning of every paragraph Windows 10 Add en-dash as the beginning of every paragraph Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,465
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

Simple:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Execute FindText:="[!^13]@^13", ReplaceWith:="^=^&", _
    MatchWildcards:=True, Format:=False, Wrap:=wdFindContinue, Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-22-2025, 06:16 PM
nonno nonno is offline Add en-dash as the beginning of every paragraph Windows 11 Add en-dash as the beginning of every paragraph Office 2021
Novice
Add en-dash as the beginning of every paragraph
 
Join Date: Mar 2023
Posts: 13
nonno is on a distinguished road
Default

Thank you Paul. Works great.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add en-dash as the beginning of every paragraph VBA Bold text at beginning of paragraph Shelley Lou Word VBA 6 11-18-2024 03:15 PM
Add en-dash as the beginning of every paragraph Replace paragraph with style and add an em dash jeffreybrown Word VBA 1 05-08-2021 04:01 PM
Add en-dash as the beginning of every paragraph Space tab at the beginning of each paragraph in a chapter village Word 3 07-20-2018 01:48 AM
Add en-dash as the beginning of every paragraph Need Word to change -- (dash,dash) into one long dash. Bobosmite Word 2 05-06-2011 04:21 AM
Dash in the beginning of a new line Wakinyan Word 0 07-11-2010 07:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:41 AM.


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