![]() |
#1
|
|||
|
|||
![]()
I have a document with a table.
In one of the rows, it has a sentence like this: door type: Flat Entry Door door material: Wood I'd like to replace all instances of this with proper formatting like this: Door Type: Flat-Entry Door Door Material: Wood I have already tried 'find and replace' to do this, but it doesn't seem to work. Can a Macro do this across the document? Of course, whatever variable comes after Door Type: and Door Material: should appear as it is but properly formatted. Formatted for Calibri (8). See my attached doc. Is there a way to do this? I use Word on a Mac. JH |
#2
|
|||
|
|||
![]()
As long as all of the current format in your working files are consistent with your sample find and replace should work fine.
Find " door type" Replace with "Door Type" Find " door material Replace with "^pDoor Material" |
#3
|
|||
|
|||
![]()
I also need to place it on two lines instead of one and format it to Calibri 8.
I may have 20 of them on one doc and so I was thinking of an easy macro. Also, the text after Door Type and Door Material could be different in different tables. JH |
#4
|
|||
|
|||
![]()
Macros aren't easy to write and this is not a macro writing service. This is a forum to help people who want to learn how to write their own macros.
Have you tried what I posted? If you did, it would not matter how many "of them" you have in the document and it wouldn't matter what text follows " door type" and " door material" Do a little research on how to write a "find and replace" macro. If you can't figure it out, then post what you tried and I or someone will be glad to help you from there. |
#5
|
||||
|
||||
![]()
For the content you provided, this macro works
Code:
Sub Macro1() Dim aRng As Range, aSty As Style Set aRng = ActiveDocument.Range Set aSty = ActiveDocument.Styles("Note Heading") aSty.Font.Name = "Calibri" aSty.Font.Size = 8 With aRng.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Style = aSty .Text = "door type:" .Replacement.Text = "Door Type:" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = True Do While .Execute(Replace:=wdReplaceOne) aRng.Paragraphs(1).Range.Font.Reset aRng.Collapse Direction:=wdCollapseEnd Loop End With Set aRng = ActiveDocument.Range With aRng.Find .Text = "door material:" .Replacement.Text = "^pDoor Material:" .Execute Replace:=wdReplaceAll End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#6
|
|||
|
|||
![]() Quote:
Can a slight adjustment be made? The original sentence either has a space before it or some text which is joined onto it (like xxxDoor type). Is there a way for the code to remove any space before the word, or separate the previous word from 'Door', and then move the whole thing onto another line anyway? So: xxxdoor type: Flat Entry Door door material: Wood would become: xxx Door Type: Flat Entry Door Door Material: Wood and door type: Flat Entry Door door material: Wood Becomes Door Type: Flat Entry Door Door Material: Wood Can an adjustment like this be made in the code? Really helpful. Thanks, JH |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sentence Template | michissimo | Word | 1 | 11-19-2020 05:53 PM |
![]() |
jeffreybrown | Word VBA | 6 | 09-07-2018 03:46 PM |
![]() |
spirituel | Word | 2 | 09-29-2015 01:50 AM |
![]() |
nrsmd | Word | 2 | 07-04-2015 10:33 PM |
![]() |
Andoheb | Word | 29 | 07-03-2014 01:48 PM |