|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to code a Find&Replace macro to remove a tab and bold the entire para
I have a Word document with interviewer questions and answers
The format is like this: <Interviewer:><^t><One or more sentence(s) with closing punctuation><^p> and I want an MS Word Find and Replace macro to convert each instance into this: <bold><Interviewer:><space><Identical One or more sentence(s) with closing punctuation><^p></bold> The macro routine would look something like this: Sub Reformat_Tabbed_Para() ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Bold = True With Selection.Find .Text = <><><><> .Replacement.Text = "\1[space]\3\4" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub I believe there is code allowing me to find and replace the same string of characters and punctuation up to the ^p but cannot find the correct way of writing it. Help would be much appreciated! |
#2
|
||||
|
||||
It is not apparent from your post whether you're working with HTML strings, or whether what you've posted is simply your attempt to represent the document content in HTML format.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
My apologies, I thought that - since this is an MS Word VBA forum and I stated that I had a "Word document" and was looking for a solution using an "MS Word Find and Replace macro" - the expressions within chevrons would be understood to be the terms used in the F&R code given below.
|
#4
|
||||
|
||||
In which case, you don't even need a macro - all you need is a single wildcard Find/Replace, where:
Code:
Find = (Interviewer:)^t([!^13]@^13) Replace = \1 \2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Thank you!
This - ([!^13]@^13) - is what I couldn't work out, was trying permutations involving (0-9A-z ) with 'ignore punctuation characters' specified, but it wasn't working. Much appreciated! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro for Find/replace to remove space before Hard Return | AlfredStreich | Word VBA | 4 | 01-23-2020 03:59 PM |
Create a macro or Find/Replace Code to delete tags | bonzai217 | Word | 2 | 08-04-2019 08:36 AM |
Macro to find and replace headings in bold and underline | redzan | Word VBA | 4 | 02-13-2016 12:24 PM |
Macro code that prompts user to enter text, then does find/replace. | sfvegas | PowerPoint | 0 | 01-10-2016 08:02 PM |
Looking for code to create a macro that prompts user to enter text, then does a find/replace. | sfvegas | PowerPoint | 0 | 01-08-2016 02:22 AM |