Results 1 to 20 of 20

Thread: Macro won't modify style in Word 2003

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2012
    Posts
    9

    Macro won't modify style in Word 2003

    I'm trying to make a macro that changes all comment text to left-to-right text. I can do this manually (create comment, change style to automatically update, then apply LTR) but the macro I record doesn't make the change. Indeed, in Word 2003 it doesn't even work while I'm recording the macro.

    Here's the code in Word 2003:

    Code:
        Selection.Comments.Add Range:=Selection.Range
        With ActiveDocument.Styles("Comment Text")
            .AutomaticallyUpdate = True
            .BaseStyle = "Normal"
            .NextParagraphStyle = "Comment Text"
        End With
        Selection.LtrPara
        With ActiveDocument.Styles("Comment Text")
            .AutomaticallyUpdate = False
            .BaseStyle = "Normal"
            .NextParagraphStyle = "Comment Text"
        End With
        WordBasic.RejectChangesSelected
    It doesn't work in Word 2007 either. The code (below) seems to basically boil down to

    Code:
    ActiveDocument.Styles("Comment Text").ParagraphFormat.Alignment = wdAlignParagraphLeft
    Here's 2007's complete code:

    Code:
        Selection.Comments.Add Range:=Selection.Range
        Selection.LtrPara
        WordBasic.FormatStyle Name:="Comment Text", NewName:="", BasedOn:="", _
            NextStyle:="", Type:=0, FileName:="", Link:=""
        With ActiveDocument.Styles("Comment Text").Font
            .Name = "Arial"
            .Size = 10
            .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("Comment Text").ParagraphFormat
            .LeftIndent = InchesToPoints(0)
            .RightIndent = InchesToPoints(0)
            .SpaceBefore = 0
            .SpaceBeforeAuto = False
            .SpaceAfter = 10
            .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("Comment Text").NoSpaceBetweenParagraphsOfSameStyle _
            = False
        ActiveDocument.Styles("Comment Text").ParagraphFormat.TabStops.ClearAll
        With ActiveDocument.Styles("Comment Text").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("Comment Text").LanguageID = wdEnglishUS
        ActiveDocument.Styles("Comment Text").NoProofing = False
        ActiveDocument.Styles("Comment Text").Frame.Delete
    Any thoughts?
    Last edited by Siddharth Rout; Jul 20th, 2012 at 02:45 PM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width