添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
没人理的路灯  ·  errorcode=-4214 ...·  1 年前    · 
俊逸的茶壶  ·  EF Linq中的左连接Left ...·  1 年前    · 
老实的小摩托  ·  Psychopy | ...·  1 年前    · 

I am walking. But I am not talking. Do you know why?

This is how I get the the active word/sentence in document:

Dim curSel = Globals.ThisAddIn.Application.Selection
Dim currWordRange As Microsoft.Office.Interop.Word.Range = selRange.Words(1)
Dim currSentenceRange As Microsoft.Office.Interop.Word.Range = selRange.Sentences(1)
Dim currWordRangeText As String = currWordRange.Text.Trim
Dim currSentenceRangeText As String = currSentenceRange.Text.Trim

Based on the cursor (selection), using the above codes, I can get the right sentence or word.

If the selection is inside a table, I have the following code:

Dim currCell As Microsoft.Office.Interop.Word.Cell 
Dim currRow As Microsoft.Office.Interop.Word.Row
Dim currTable As Microsoft.Office.Interop.Word.Table = selRange.Tables(1)
currCell = currTable.Range.Cells(1)
currRow = currTable.Range.Rows(1)

currCell.Range.Text will return=> I am walking. But I am not talking. Do you know why?
currCell.Range.Sentences(1).Text will return=> I am walking.

Let say I typed some word after the original text sample.

I am walking. But I am not talking. Do you know why? Because I don't

From the above sample, how do I get the "Because I don't" text? Of course I can set the indexes for Sentences to 4 to get the text. But the number of sentences could be anything and the selection also could be anywhere in the text sample.

Thank you in advance for any help/idea.