#1
|
|||
|
|||
Selecting table but can't see top of table
I have multiple tables I'm trying to update, but some tables have a name row so I have to perform a different action. Currently the table name is simply above the table, but not actually part of the table. Here is a slimmed down version of my macro. The problem I'm running into, the table is selected, but I can't see the top of the table to be able to answer the question as to whether this particular table has a table name. I realize typically you do not have to select an object to work with it, but in this case I need to see the top of the table. Code:
Sub UpdateTables() Application.ScreenUpdating = False Dim x As Long Dim MyTables As Long: MyTables = ActiveDocument.Tables.Count Dim MyNote As String: MyNote = "Does this table have a table name" Dim answer As String For x = 1 To MyTables With ActiveDocument.Tables(x) .Select answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Option!") Select Case answer Case vbYes MsgBox "You answered Yes" Case vbNo MsgBox "You answered No" End Select End With Next x Application.ScreenUpdating = True End Sub |
#2
|
||||
|
||||
Try this
Code:
Sub UpdateTables() Dim x As Long Dim MyTables As Long: MyTables = ActiveDocument.Tables.Count Dim MyNote As String: MyNote = "Does this table have a table name" Dim answer As String Dim aRng As Range Application.ScreenUpdating = False For x = 1 To MyTables With ActiveDocument.Tables(x) Set aRng = .Range aRng.MoveStart Unit:=wdParagraph, Count:=-1 aRng.Select ActiveWindow.ScrollIntoView aRng, True 'your other code here End With Next x Application.ScreenUpdating = True End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks Andrew. That seems to work.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Code to find a named (bookmarked?) table, replicate a row or table, and delete a specified table. | kevinbradley57 | Word VBA | 9 | 09-21-2017 04:58 PM |
Problem with table grid when selecting status in ribbon | lodi123 | Word VBA | 1 | 02-24-2017 05:32 AM |
Selecting table cell vs. text | dionnaro | Word Tables | 1 | 05-24-2016 04:04 PM |
Selecting values from different rows in a table and sort them in order in a single row | FromF | Excel | 2 | 09-09-2014 02:30 AM |
Selecting/deselecting items in pivot table | mbesspiata | Excel | 0 | 07-22-2014 08:15 AM |