![]() |
|
#1
|
|||
|
|||
![]()
Please ignore the word 'Selection'. What I need is a modification of the code below so as to replace each m-dash with an n-dash.
Code:
Sub DASHES() 'Testo e Note: Sostituisce m-dash con n-dash Dim mStory As Range 'Nel testo e nelle note Dim mRange As Range For Each mStory In ActiveDocument.StoryRanges 'Ranges = testo e note mStory.Find.Execute FindText:="^#" & Chr(150) & "^#", ReplaceWith:=Chr$(45) Next mStory Set mStory = Nothing End Sub |
#2
|
|||
|
|||
![]()
Hi, RobiNew! If undersatand correctly what you want, try the following. But note that m-dash has code 151 and n-dash has code 150.
Code:
Sub DASHES() 'Testo e Note: Sostituisce m-dash con n-dash Dim mStory As range 'Nel testo e nelle note Dim mRange As range For Each mStory In ActiveDocument.StoryRanges mStory.Find.Execute FindText:="([0-9])" & Chr(151) & "([0-9])", _ ReplaceWith:="\1" & Chr(150) & "\2", _ MatchWildcards:=True, _ Replace:=wdReplaceAll Next mStory End SUb |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
find and replace only in current selection | Bikram | Word VBA | 4 | 11-12-2021 07:31 AM |
Find and replace numbers (up to three digits) | ballpoint | Word | 3 | 06-13-2018 08:58 AM |
![]() |
imported_contiw | Word | 14 | 10-04-2017 01:03 PM |
Macro to replace digits with letters | Bananabean | Word VBA | 6 | 09-14-2013 09:28 PM |
![]() |
Glynda | Mail Merge | 1 | 04-08-2011 12:17 AM |