【问题标题】:Add loop to bullet formatting将循环添加到项目符号格式
【发布时间】:2015-04-30 13:30:57
【问题描述】:

我从一个基本的宏开始,在我的文档中查找任何项目符号,然后通过录制一个应用我们公司项目符号样式的宏来添加它。但是,我无法插入循环并不断收到错误消息。

有没有一种简单的方法来清理它并让它贯穿整个文档?

Sub FindAndReplacewithCompanyBullet()

 Application.Run MacroName:="FindBullet"
 Selection.Style = ActiveDocument.Styles("Company Bullet List")
 With Selection.ParagraphFormat
    .SpaceBeforeAuto = False
    .SpaceAfterAuto = False
    .FirstLineIndent = InchesToPoints(-0.38)
 End With
 With Selection.ParagraphFormat
    .LeftIndent = InchesToPoints(0.44)
    .SpaceBeforeAuto = False
    .SpaceAfterAuto = False
 End With
 With Selection.ParagraphFormat
    .SpaceBeforeAuto = False
    .SpaceAfterAuto = False
    .FirstLineIndent = InchesToPoints(-0.31)
 End With
 With Selection.ParagraphFormat
    .LeftIndent = InchesToPoints(0.31)
    .SpaceBeforeAuto = False
    .SpaceAfterAuto = False
 End With
  With Selection.ParagraphFormat
    .SpaceBeforeAuto = False
    .SpaceAfterAuto = False
    .FirstLineIndent = InchesToPoints(-0.18)
 End With
Next Para
End Sub

【问题讨论】:

  • Nest Para 是什么?

标签: vba ms-word editing


【解决方案1】:

我想你想要这个:

Dim values(3,2) As Single, I as Integer
values(1,1) = -0.38
values(1,2) = 0.44
values(2,1) = -0.31
values(2,2) = 0.44
values(3,1) = -0.18
values(3,2) = 0

For i = 1 To 3
    With Selection.ParagraphFormat
        .SpaceBeforeAuto = False
        .SpaceAfterAuto = False
        .FirstLineIndent = InchesToPoints(values(i,1))
        If values(i,2) <> 0 Then
            .LeftIndent = InchesToPoints(values(i,2))
        End If
     End With
Next i

【讨论】:

  • 对于“.FirstLineIndent = InchesToPoints (values(2, I))”的行,我不断收到“运行时错误'9':下标超出范围”。我怎样才能解决这个问题?谢谢。
  • @CatherineCombs 这是我的错,检查新代码;)。
猜你喜欢
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-12
  • 1970-01-01
相关资源
最近更新 更多