I have a Word document, with the first two sentences as normal text and sentences three and four in a table (in one cell):
My first sentence. My second sentence.
My third sentence. My fourth sentence.
My code is the following:
Option Explicit
Sub test()
Dim sentence As Variant
Dim i As Long: i = 0
Selection.Expand wdSentence
Debug.Print "--------->" & ActiveDocument.ActiveWindow.Selection.Sentences.Count
Debug.Print "selection: " & ActiveDocument.ActiveWindow.Selection
For Each sentence In ActiveDocument.ActiveWindow.Selection.Sentences
i = i + 1
Debug.Print i & " sentence: " & sentence
Next
End Sub
If I select the first two sentences, the debug output is correct:
--------->2
selection: My first sentence. My second sentence.
1 sentence: My first sentence.
2 sentence: My second sentence.
If I select the two sentences in the table, the debug output is strange (or wrong?):
--------->2
selection: My third sentence. My fourth sentence.
1 sentence: My third sentence.
Why is the output of the table content different from normal text? How can I get the same result for the table content as for the normal text?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…