vba - 根据多种字体条件替换 Word VBA 中的文本
问题描述
我正在尝试删除所有带有字体的单词。name.FarEast="Georgia" 和 font.name="Verdana", Bold=true 在文档中,但我找不到 vba 的任何查找功能...(我可以手动设置查找格式)任何人都可以帮忙我和那个?
我已经用尽了我的搜索方法,找不到答案
With Selection.Find.Bold = True
.ClearFormatting
Selection.Font.NameFarEast = "Georgia"
.Font.Name = "Verdana"
.Execute FindText:="", ReplaceWith:="", Format:=True, _
Forward:=True
End With
'似乎根本不起作用
它只是显示
“未找到方法或数据”
解决方案
您可以遍历所有单词并检查条件。
Sub test1()
Dim sen As Object
Dim wd As Object
For Each sen In ActiveDocument.StoryRanges(1).Sentences
For Each wd In sen.Words
With wd
If .Bold = True And .Font.Name = "Verdana" And .Font.NameFarEast = "Georgia" Then
wd.Select
Selection.Text = ""
End If
End With
Next
Next
End Sub
演示: 只检查粗体字
推荐阅读
- javascript - 在 d3 库中的可缩放圆包图中添加边
- php - 如何删除字符串中两行之间的特定换行符而不删除其他换行符?php
- javascript - Nuxt 来自 api 的动态路由
- apache-kafka - 使用 localstack 测试 kafka 应用程序
- validation - wxPython 对话框:如何验证多个控件中的输入?
- javascript - primeng p-treeTableToggler 图标已更改,而不是原来的 pi pi-fw pi-chevron-right 图标
- pandas - 如何根据检查列中是否存在值的条件将行添加到 DF
- vue.js - 无法让 v-img 在 v-flex 内居中
- lua - 将字符串与函数 Lua 关联
- reactjs - 找不到所需的文件。名称:index.js