我尝试将无序HTML列表(<ul>
)更改为Office Word项目符号列表。我录制了一个宏来看看Word如何处理明文到子弹列表转换,我已经迷失并惊讶于这样一个看似简单的任务在VBA中如此复杂。文本格式如下:
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
我以为我可以搜索并选择<ul>
到</ul>
中的内容并运行以下代码(我记录的代码):
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = CentimetersToPoints(0.63)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(1.27)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:= _
False, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _
wdWord10ListBehavior
Selection.EscapeKey
但首先我需要一种方法来选择带有<ul>
标签的文字,如果可能的话,请删除这些文字(可能是Replace(decodeHTML, "<ul>", "")
)
感谢任何帮助!