![]() |
#1
|
|||
|
|||
![]()
Hi guys,
I'm wondering if there is a possibility to refer to the last table in a Word document. I need to insert a graphic in the last table, but it is possible that the number of tables inside the document will change. So I can't use the Tables(X) in the code. Now I got this: Sub ShowInterim(control As IRibbonControl) With ActiveDocument Dim oBB As BuildingBlock Dim oRng As Range Dim oField As Field Dim oSection As Section Dim oHeader As HeaderFooter Dim oFooter As HeaderFooter Set oRng = ActiveDocument.Tables(18).Rows(1).Cells(1).Range oRng.End = oRng.End - 1 'to exclude the end of cell marker Set oBB = ActiveDocument.AttachedTemplate.BuildingBlockEntri es("Interim") oBB.Insert Where:=oRng, RichText:=True For Each oSection In ActiveDocument.Sections For Each oHeader In oSection.Headers If oHeader.Exists Then For Each oField In oHeader.Range.Fields oField.Update Next oField End If Next oHeader Next oSection End With End Sub Is there a possibility like Table(Last) or something to fix this? The last table will also be on the last page of the document, if this helps. |
#2
|
|||
|
|||
![]()
Have you tried:
ActiveDocument.Tables(ActiveDocument.Tables.Count) .Rows(1).Cells(1).Range |
#3
|
|||
|
|||
![]()
Oh wow this is great!! Thank you so much!!
|
![]() |
Tags |
insert graphic, last page, last table |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
snufse | Word VBA | 1 | 11-10-2015 03:28 PM |
![]() |
jklein | Word Tables | 5 | 06-29-2014 07:40 PM |
![]() |
natasha_arriell | Mail Merge | 4 | 06-04-2014 12:13 AM |
Convert graphic to text in a table | Jennifer Murphy | Word | 6 | 01-24-2013 12:56 PM |
Inserting a table | Katelyn | Outlook | 0 | 04-05-2012 09:39 AM |