Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-07-2021, 07:26 PM
Bikram Bikram is offline Format text between two styles Windows 10 Format text between two styles Office 2007
Advanced Beginner
Format text between two styles
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Post Format text between two styles

I am beginner in vba hoping for some guidelines to automate my daily task. So, any help would be greatly appreciated.

Here is my code

Sub find_and_format()
Dim doc As Document
Dim rng As Range


Set doc = Application.ActiveDocument


Set rng = doc.Content

With rng.find
.ClearFormatting
.Text = "Answer"
.Style = ActiveDocument.Styles("ans")
.Format = False
.MatchAllWordForms = False
.MatchWildcards = False
.MatchCase = False
.Wrap = wdFindContinue
End With


Do Until rng.find.Execute = False
Selection.MoveDown unit:=wdParagraph, Count:=1
Selection.Style = ActiveDocument.Styles("t")
Selection.MoveDown unit:=wdParagraph, Count:=1
'do while manual numbering is found
Do While Selection.Range.ListFormat.ListType = wdListSimpleNumbering
' and then i want to select and change the autonumbering to manual numbering
Selection.Range.ListFormat.ConvertNumbersToText
Selection.Style = ActiveDocument.Styles("tt")

' or repeat this process until another style is found
Loop
'can i access the range between a style to another style and then format it??


Loop

'i have attached a sample file



End Sub
Attached Files
File Type: docx Sample.docx (21.3 KB, 11 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Styles in Templates to help format text - Importing and working with Templates daithy Word 2 01-03-2020 05:06 PM
Format text between two styles help with citations styles, xsl file format LMHmedchem Word 2 10-22-2014 10:40 AM
Format text between two styles Problem with using Styles to format text. cummins Word 3 08-16-2012 05:34 AM
Styles format not permanent Zuca Word 1 07-02-2010 10:02 PM
Creating/editting citation format styles shark0807 Word 1 10-01-2008 07:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 PM.


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