Solved Macro parameters are being ignored...

Toshiba Satellite c55-a5300 15.6 laptop...
July 6, 2015 at 10:41:12
Specs: Windows 7, 4 GB
In MS Word I created a macro, which included a specification for paragraph spacing. The Spacing Before and After values were 10 pt and 0 pt respectively. Then I realized the values should have been reversed, so I opened the macro for editing and changed the values as follows:
.SpaceBefore = 0 pt
.SpaceAfter = 10 pt

However, doing so seems to have had no effect on the paragraph spacing. The paragraph created by running the macro retains its original paragraph spacings of 10/0, despite the fact that the macro code displays the new values.

Anyone know why I can't get the macro to behave? BTW, I'm using MS Word 2013.
Thanks.
howagood

howagood


See More: Macro parameters are being ignored...

Report •


#1
July 6, 2015 at 11:16:10
✔ Best Answer
It's hard for us to troubleshoot your code with the limited information provided. For all we know, there are other instructions in your code that impact those settings or those instructions are part of an If-Then loop that is not executing or any of a number of different circumstances.

Please use the pre tags and post your entire macro so that we see the code and maybe even test it.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
July 6, 2015 at 12:50:33
Just for fun, I created the following macro. If you open a document and set up your screen to watch the Page Layout tab while using F8 to Single Step through the code, you can watch the Spacing...Before: and After: fields toggle between 10/0...0/10 each time through the loop.

Sub toggleParaSpace()
'Initialize SpaceBefore, SpaceAfter Variables
   sb = 0: sa = 10
'Select All
   Selection.WholeStory
'Loop 5 times, Toggle Paragraph Spacing
  For toggle = 1 To 5
    With Selection.ParagraphFormat
        .SpaceBefore = sb
        .SpaceAfter = sa
    End With
'Toggle Paragraph Space Settings
      If sb = 0 Then
         sb = 10: sa = 0
      Else
         sb = 0: sa = 10
      End If
  Next
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

message edited by DerbyDad03


Report •

#3
July 7, 2015 at 05:51:59
Good morning, DerbyDad03. Here is the full code of the macro in question:

Sub Bullet1()
'
' Bullet1 Macro
' Creates first-level bullet
'
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 10
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.15)
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(-0.25)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With
With Selection.Font
.Name = "Arial"
.Size = 11
.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
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
.Ligatures = wdLigaturesNone
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3913, Unicode:= _
True
Selection.TypeText Text:=vbTab
Selection.TypeParagraph
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 10
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.15)
.Alignment = wdAlignParagraphJustify
.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
.CollapsedByDefault = False
End With
End Sub

howagood


Report •

Related Solutions

#4
July 7, 2015 at 08:05:30
I see that you did not follow my instructions to use the pre tags when posting your code.

Please click on the following line and read the instructions found via that link.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#5
July 7, 2015 at 08:42:06
Your code works for me. Are you sure that you are running it with a paragraph Selected?

The code is written to operate on a "Selection" so you won't see any difference if there is nothing Selected or if the Selection is already set to the Spacing you want.

With Selection.ParagraphFormat

If I Select a bunch of text and then Single Step through the code via F8, I can see both the Selected text change it's spacing as well as the Spacing...Before: and After: fields on the Page Layout ribbon.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

Ask Question