Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 11-21-2023, 04:21 PM
Guessed's Avatar
Guessed Guessed is offline Replacing a Sentence with New Format Windows 10 Replacing a Sentence with New Format Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sentence Template michissimo Word 1 11-19-2020 05:53 PM
Replacing a Sentence with New Format VBA: Set two styles in one sentence jeffreybrown Word VBA 6 09-07-2018 03:46 PM
Replacing a Sentence with New Format I want to know how to format a sentence after beginning it with an automatic number spirituel Word 2 09-29-2015 01:50 AM
Replacing a Sentence with New Format End of sentence puncuation. nrsmd Word 2 07-04-2015 10:33 PM
Replacing a Sentence with New Format Delete does not bring second sentence closer to first sentence Andoheb Word 29 07-03-2014 01:48 PM

Other Forums: Access Forums

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