Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2021, 01:55 AM
stky stky is offline Need create style Windows 10 Need create style Office 2013
Advanced Beginner
Need create style
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default Need create style


Need to create style with in e.g: (<H1>, <H2>, <H3>... etc...)

and for character style need create

bold as cBold
italic as cItalic

...etc.

In all stories.
Attached Files
File Type: docx SAMPLE_File.docx (16.0 KB, 9 views)
Reply With Quote
  #2  
Old 10-31-2021, 02:18 PM
Guessed's Avatar
Guessed Guessed is offline Need create style Windows 10 Need create style Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,027
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

This should get you started
Code:
Sub StyleItUp()
  Dim aRng As Range
  Set aRng = ActiveDocument.Range
  With aRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<CN>"
    .Replacement.Style = "Heading 1"
    .Execute Replace:=wdReplaceAll
    
    .Text = "<CT>"
    .Replacement.Style = "Heading 2"
    .Execute Replace:=wdReplaceAll
    
    .Text = "<TX>"
    .Replacement.Style = "Body Text"
    .Execute Replace:=wdReplaceAll
    'repeat above pattern for all paragraph styles
    
    'now search for font attributes and apply character styles
    .Text = ""
    .Font.Bold = True
    .Replacement.ClearFormatting
    .Replacement.Style = "Strong"
    .Execute Replace:=wdReplaceAll
    
    .ClearFormatting
    .Font.Italic = True
    .Replacement.ClearFormatting
    .Replacement.Style = "Emphasis"
    .Execute Replace:=wdReplaceAll
    
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need create style need to find and create style stky Word VBA 3 04-23-2021 10:51 PM
Create text box in VBA and style content dpashley Word VBA 2 08-01-2017 01:40 AM
Need create style Modify or create a style otuatail Word 3 09-12-2016 12:20 PM
Need create style I create a new style but it fails to appear in Quick Style list veronius Word 6 06-18-2013 06:29 PM
Need create style How do I create a style that changes only the color??? wornways Word 1 12-21-2011 04:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft