View Single Post
 
Old 11-26-2019, 05:09 PM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default 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
Reply With Quote