We help IT Professionals succeed at work.
Get Started

Creat Word 2007 Style using a Macro

ALawrence007 asked
Last Modified: 2012-06-21
Hi to all the experts,

I have a unique question so please bear with me.
I have a word document with various styles in the document. I need a Macro to take all those styles and create them as quick styles for that document. I am trying to roll up a bunch of word documents into one final one, but all documents inherit the first documents style. I spoke with Microsoft and they said the only way to do this is to create quick styles that is then part of the document. That way all documents will not inherit the first documents style. I have a sample of where I recorded a Macro to create one style and would like to be able to automate this process for the whole document.

Any help would be appreciated.
Thanks to all
Sub Style()
' Style Macro
    WordBasic.FormatStyle Name:="ArialBlack22", NewName:="", BasedOn:="", _
        NextStyle:="", Type:=0, FileName:="", Link:=""
    WordBasic.FormatStyle Name:="ArialBlack22", NewName:="", BasedOn:="", _
        NextStyle:="", Type:=0, FileName:="", Link:=""
    With ActiveDocument.Styles("ArialBlack22").Font
        .Name = "Arial Black"
        .Size = 22
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Scaling = 100
        .Kerning = 0
        .Animation = wdAnimationNone
    End With
    With ActiveDocument.Styles("ArialBlack22").ParagraphFormat
        .LeftIndent = InchesToPoints(0)
        .RightIndent = InchesToPoints(0)
        .SpaceBefore = 0
        .SpaceBeforeAuto = False
        .SpaceAfter = 0
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceSingle
        .Alignment = wdAlignParagraphLeft
        .WidowControl = True
        .KeepWithNext = False
        .KeepTogether = False
        .PageBreakBefore = False
        .NoLineNumber = False
        .Hyphenation = True
        .FirstLineIndent = InchesToPoints(0)
        .OutlineLevel = wdOutlineLevelBodyText
        .CharacterUnitLeftIndent = 0
        .CharacterUnitRightIndent = 0
        .CharacterUnitFirstLineIndent = 0
        .LineUnitBefore = 0
        .LineUnitAfter = 0
        .MirrorIndents = False
        .TextboxTightWrap = wdTightNone
    End With
    ActiveDocument.Styles("ArialBlack22").NoSpaceBetweenParagraphsOfSameStyle _
        = False
    With ActiveDocument.Styles("ArialBlack22").ParagraphFormat
        With .Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorAutomatic
            .BackgroundPatternColor = wdColorAutomatic
        End With
        .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
        .Borders(wdBorderRight).LineStyle = wdLineStyleNone
        .Borders(wdBorderTop).LineStyle = wdLineStyleNone
        .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
        With .Borders
            .DistanceFromTop = 1
            .DistanceFromLeft = 4
            .DistanceFromBottom = 1
            .DistanceFromRight = 4
            .Shadow = False
        End With
    End With
    ActiveDocument.Styles("ArialBlack22").LanguageID = wdEnglishUS
    ActiveDocument.Styles("ArialBlack22").NoProofing = False
End Sub

Open in new window

Watch Question
Top Expert 2011
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE