PDA

View Full Version : vba to select and copy whole table



samuelimtech
05-06-2016, 06:02 AM
hi,

im looping through a document by paragraphs and when i reach a table i want to do something slightly different.

i use the paragraph.Range.Information(wdWithinTable) to recognise that the selection is within a table.
once im here is it possible to select/copy the whole table and count the total number of cells?

thanks


If Selection.paragraph.Range.Information(wdWithinTable) Then


MsgBox Selection.Table.Cells.Count


End If

gmaxey
05-06-2016, 09:03 AM
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
If Selection.Range.Paragraphs(1).Range.Information(wdWithInTable) Then
MsgBox Selection.Tables(1).Range.Cells.Count
End If
'Or
On Error Resume Next
MsgBox Selection.Tables(1).Range.Cells.Count
On Error GoTo 0
lbl_Exit:
Exit Sub
End Sub