Get table text – VBA word

Posted: decembar 5, 2011 in Uncategorized
Oznake:,

Kod za tabelu u word-u

Private Sub GetTableText()
If Not Selection.Information(wdWithInTable) Then Exit Sub
‘Get Column and Row of cell containing the button that launched this event.
Dim c As Long, r As Long
c = CLng(Selection.Information(wdStartOfRangeColumnNumber))
r = CLng(Selection.Information(wdStartOfRangeRowNumber))
‘Get all text from each cell in this row, bar the current cell.
Dim cels As Cells, i As Long, s As String
cels = Selection.Range.Tables(1).Rows(r).Cells
For i = 1 To c – 1
s = s & StripJunk(cels(i).Range.Text) & vbTab
Next
s = Left(s, Len(s) – 1)
MsgBox(„|“ & s & „|“)
End Sub
Private Function StripJunk(ByVal s As String)
StripJunk = Trim(Replace(s, vbCr & Chr(7), „“))
End Function
Private Sub CommandButton1_Click()
GetTableText()
End Sub
Private Sub CommandButton2_Click()
GetTableText()
End Sub
Private Sub CommandButton3_Click()
GetTableText()
End Sub
Private Sub CommandButton4_Click()
GetTableText()
End Sub
Private Sub CommandButton5_Click()
GetTableText()
End Sub
Private Sub CommandButton6_Click()
GetTableText()
End Sub
Private Sub CommandButton7_Click()
GetTableText()
End Sub
Private Sub CommandButton8_Click()
GetTableText()
End Sub

Advertisements

Zatvoreno za komentare.