Search code examples
vb.netms-wordcell

vb.net get cell value from word file table


I have some code to get cell value from a word file table.

But it contains something like 口 and will generate a line which is useless, how can I remove this character?

Dim num As String = Trim$(wordApp.ActiveDocument.Tables.Item(1).Cell(6,1).Range.Text)
    MsgBox(num)

output is this.

But I'm sure the original cell value doesn't have a empty line.


Solution

  • For example (with VBA):

    String = Split(wordApp.ActiveDocument.Tables.Item(1).Cell(6,1).Range.Text, vbCr)(0)
    

    The ¤ is Word's end-of-cell marker, which you need to exclude.