![]() |
#6
|
|||
|
|||
![]()
There is a bit here called Learn to Love ranges.
VBA Basics Actual a table is an object (type table). Declaring a variable just makes coding easier. (I'm not formally trained so could be wrong). Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oTbl As Object Dim oTbl2 As Table Dim lngIndex As Long For Each oTbl In ActiveDocument.Tables MsgBox TypeName(oTbl) oTbl.Range.Cells(1).Range.Text = "AAA" MsgBox oTbl.Rows.Count Next oTbl For Each oTbl2 In ActiveDocument.Tables oTbl2.Range.Cells(1).Range.Text = "BBB" MsgBox oTbl2.Rows.Count Next oTbl2 For lngIndex = 1 To ActiveDocument.Tables.Count ActiveDocument.Tables(lngIndex).Range.Cells(1).Range.Text = "CCC" MsgBox ActiveDocument.Tables(lngIndex).Rows.Count Next lbl_Exit: Exit Sub End Sub Last edited by gmaxey; 08-19-2019 at 04:19 AM. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
syntax for inserting blank line before inserting table and after a line or paragraph | SamDsouza | Word VBA | 8 | 08-04-2019 11:10 PM |
Inserting graphic in last table | lodi123 | Word VBA | 2 | 07-07-2017 06:48 AM |
![]() |
snufse | Word VBA | 1 | 11-10-2015 03:28 PM |
![]() |
natasha_arriell | Mail Merge | 4 | 06-04-2014 12:13 AM |
Inserting a table | Katelyn | Outlook | 0 | 04-05-2012 09:39 AM |