Word vba之遍历段落、识别固定段头、设置样式
?Python包的help信息規律比較明顯,簡單處理后用導航窗格能比較方便的查看類和方法信息。
不過對vba的空格處理還沒認真研究,處理后會有一些不完美的地方,湊夠用了。
Sub Pypackhelp()
'
' Pypackhelp 宏
'
'
? ? Dim pg As Paragraph, r As Range
? ? For Each pg In ActiveDocument.Paragraphs
? ? ? ? pgtext = pg.Range.Text
? ? ? ? If InStr(1, pgtext, " ? ?class") <> 0 Then ?'如果找到類的匹配項
? ? ? ? ? ? pg.Style = ActiveDocument.Styles("class") ? 'class為樣式名
? ? ? ? End If
? ? ? ??
? ? ? ? If (InStr(1, pgtext, " ? ? | ?") <> 0 And InStr(1, pgtext, " ? ? | ? ?") = 0 And InStr(9, pgtext, "(") <> 0) Then
? ? ? ? '如果找到方法的匹配項,第二個條件為什么沒用?空格要怎么處理?
? ? ? ? ? ? pg.Style = ActiveDocument.Styles("method")
? ? Next
End Sub
?
總結
以上是生活随笔為你收集整理的Word vba之遍历段落、识别固定段头、设置样式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 配置虚拟机NAT模式连通外网并使用Xsh
- 下一篇: 免费smtp服务器地址参数