如标题所示。
我的宏是:
Sub StyleFollowingBodyText()
' Charles Kenyon 15 December 2024
' Set the following style for most QuickStyle paragraph styles to be Body Text
Dim StyleCount As Long
Dim thisStyle As Style
Dim iCount As Long
'
With ActiveDocument
Let StyleCount = .Styles.Count
For iCount = 1 To StyleCount
Let thisStyle = .Styles(iCount)
If thisStyle.QuickStyle = True Then
If thisStyle.Type = wdStyleTypeParagraph Or wdStyleTypeLinked Then
If thisStyle.NameLocal <> "Normal" Then
thisStyle.NextParagraphStyle = "Body Text"
End If
End If
End If
Next iCount
End With
End Sub
我在运行时收到此错误消息:
停在
Let thisStyle = .Styles(iCount)
。
该宏的目的是更改大部分段落的 QuickStyles,使其正文文本样式如下所示。我正在尝试更改 50 多个[快速]样式集,因为我不想让大部分文档使用普通样式。
我只是使用 .Styles(iCount) 而不是变量 StyleCount。
Sub StyleFollowingBodyText2()
' Charles Kenyon 15 December 2024
' Set the following style for most QuickStyle paragraph styles to be Body Text
Dim StyleCount As Long
Dim thisStyle As Style
Dim iCount As Long
'
With ActiveDocument
Let StyleCount = .Styles.Count
For iCount = 1 To StyleCount
' Let thisStyle = .Styles(iCount)
If .Styles(iCount).QuickStyle = True Then
If .Styles(iCount).Type = wdStyleTypeParagraph Or wdStyleTypeLinked Then
If .Styles(iCount).NameLocal <> "Normal" Then
.Styles(iCount).NextParagraphStyle = "Body Text"
End If
End If
End If
Next iCount
End With
End Sub
我不知道“为什么”,但很高兴我可以让它做我想做的事。