2
A
回答
1
如何:
Dim s As Range
For Each s In ActiveDocument.Sentences
If s.Characters(1).Bold = True Then
Debug.Print s
End If
Next
我不太看你的「選擇」的意思,你可以使用s.Select
,但它只會爲一句話工作。
編輯再評論
大致來說:
Dim s As Range
Dim doc1 As Document
Dim doc2 As Document
Set doc1 = Word.Documents("Doc1.doc")
Set doc2 = Word.Documents("Doc2.doc")
For Each s In doc1.Sentences
If s.Characters(1).Bold = True Then
Debug.Print s
doc2.Select
Selection.Find.ClearFormatting
With Selection.Find
''.Text cannot be set to more than 256 characters
.Text = s
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
a = Selection.Find.Execute
If a = True Then
Selection.Characters(1).Font.Bold = True
''Or for the whole sentence
Selection.Font.Bold = True
End If
doc1.Select
End If
Next
編輯再評論#2
兩個文件進行比較是相同的,所以也許:
Dim doc1 As Document
Dim doc2 As Document
Dim i As Integer
Set doc1 = Word.Documents("Doc1.doc")
Set doc2 = Word.Documents("Doc2.doc")
If doc1.Sentences.Count <> doc2.Sentences.Count Then
MsgBox "These two documents do not match."
Exit Sub
End If
For i = 1 To doc1.Sentences.Count
If doc1.Sentences(i).Characters(1).Bold = True Then
''Debug.Print doc1.Sentences(i)
If doc1.Sentences(i).Text = doc2.Sentences(i).Text Then
doc2.Sentences(i).Bold = True
Else
MsgBox "Sentences do not match."
End If
End If
Next
相關問題
- 1. 使用word vba可以在選擇一個句子時檢測字體嗎?
- 2. 從madlib中選擇一個句子python
- 3. Word vba多表選擇
- 4. Javascript在textarea中選擇一個句子
- 5. 用where子句選擇一個列Eloquent
- 6. Word宏,存儲當前選擇(VBA)
- 7. 從第4行開始選擇Word VBA
- 8. Word VBA添加行選擇的長度
- 9. 選擇語句只選擇一個值
- 10. 選擇Where子句
- 11. 在if語句中選擇一個範圍(Excel2010/VBA)
- 12. 選擇並刪除Word標題到下一頁打破宏VBA
- 13. 使用選擇對象(vba)從word文檔獲取一行
- 14. 從一個巨大的字符串中選擇一個句子
- 15. 從多個形狀對象中選擇並插入Word vba
- 16. 與選擇子更新語句選擇
- 17. 子選擇在一個where-in子句中
- 18. ORDER BY子句受另一個表中的子選擇約束
- 19. 如何一起選擇與WHERE子句
- 20. SQLite:多選擇語句與一個選擇語句
- 21. 子查詢的列數太多;多個選擇在一個選擇語句
- 22. 如何在word vba腳本中選擇一個特定的字符串?
- 23. MS Word VBA - 選擇範圍,檢查拼寫並接受第一個建議
- 24. Word中的VBA複選框
- 25. Word 2010 VBA複選框
- 26. sql語句和或選擇(訪問VBA)
- 27. 如何使用Word VBA將多選列表框值返回到一個句子中?
- 28. SQL從一個表中選擇多個子句
- 29. 如何選擇一個句子的前10個單詞?
- 30. SQL Select子選擇語句
是我意味着選擇。實際上有兩個包含相同上下文的單詞文檔。其中一個包括一些大膽的斜體標題等。我想在第一個文檔中找到它們,並在第二個文檔中進行粗體處理。 – tebdilikiyafet 2011-02-11 23:07:14