Numerical value of the table cell

S

StevenM

To: Aleksander,

Of course, it depends on what type of numbers your table has, but ...

Sub ReadNumbersFromTable()
Dim nRow As Long
Dim nCol As Long
Dim sStr As String
Dim sgNum As Single

For nRow = 1 To ActiveDocument.Tables(1).Rows.Count
For nCol = 1 To ActiveDocument.Tables(1).Rows(nRow).Cells.Count
sStr = ActiveDocument.Tables(1).Cell(nRow, nCol).Range.Text
sStr = Left(sStr, Len(sStr) - 2)
If IsNumeric(sStr) Then
sgNum = CSng(sStr)
MsgBox sgNum
End If
Next nCol
Next nRow
End Sub

Steven Craig Miller
 
A

Aleksander

Hello,

How is it possible to obtain the numerical value of the Word table cell using VBA? For example,

Dim Table1 As Table
Set Table1 = ThisDocument.Tables.Item(1)

The problem is to convert Table1.Cell(1,1) to the value of the numerical type.

Sincerely,
Aleksander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top