Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-26-2019, 05:09 PM
jeffreybrown jeffreybrown is offline Selecting table but can't see top of table Windows 10 Selecting table but can't see top of table Office 2016
Expert
Selecting table but can't see top of table
 
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
  #2  
Old 11-26-2019, 07:03 PM
Guessed's Avatar
Guessed Guessed is online now Selecting table but can't see top of table Windows 10 Selecting table but can't see top of table Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 11-26-2019, 07:23 PM
jeffreybrown jeffreybrown is offline Selecting table but can't see top of table Windows 10 Selecting table but can't see top of table Office 2016
Expert
Selecting table but can't see top of table
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thanks Andrew. That seems to work.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting table but can't see top of table 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
Selecting table but can't see top of table Problem with table grid when selecting status in ribbon lodi123 Word VBA 1 02-24-2017 05:32 AM
Selecting table but can't see top of table Selecting table cell vs. text dionnaro Word Tables 1 05-24-2016 04:04 PM
Selecting table but can't see top of table 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft