Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 12-08-2019, 06:39 AM
jeffreybrown jeffreybrown is offline Create heading row for table Windows 10 Create heading row for table Office 2016
Expert
Create heading row for table
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Paul,

This worked except for the first new row did not size with the table.

I found a thread where you suggested to remove the table and place in Excel, unmerge the cells there and then put back into Word.

This might work well for my needs as I don't think table with vertically merged cells will be a large number.

So, my thought, do as I mentioned above, but run my original code but add a skip when vertically merged cells are identified. As those tables are identified, I can write down the table number and deal with them one by one.

I found this, but is this the best to skip? I only need to display and then skip if vertical merged cells are identified, but I don't need the message that gives the error description.

Code:
Sub tableformat()
    Dim i As Long
    Dim oRow As Row
    Dim oCol As Column
    On Error GoTo ErrHandler
    For i = 1 To Selection.Tables.Count
        For Each oRow In Selection.Tables(i).Rows
        Next oRow
NextStep:
        For Each oCol In Selection.Tables(i).Columns
        Next oCol
NextTable:
    Next i
    Exit Sub
ErrHandler:
    Select Case Err
        Case 5991
            MsgBox "Table #" & i & " has vertically merged cells"
            Resume NextStep
        Case Else
            MsgBox "Error " & Err.Number & ": " & _
                Err.Description & " in table #" & i
            Resume NextTable
    End Select
End Sub
Note: On further looking, I see the two errors are for checking for merged rows and then checking merged columns. In my case, the original error in post #1 was due to the vertically merged and not the horizontal. So far in all the tables I've been cleaning up have multiple column merged and never an error adding the top row.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create heading row for table Want to copy & paste a table underneath itself x no. of time, table found through style heading name fly545 Word VBA 11 01-16-2020 05:53 PM
Can I create a page number from a non-Heading style? techwriter3k Word 9 09-25-2019 06:58 AM
Deleting Blank Space between table heading and table rows Pete Jones Word Tables 5 01-22-2018 04:11 PM
Create heading row for table Heading row disappears from table styles when pasted table is selected andrewballem Word Tables 2 11-12-2013 05:18 AM
Create heading row for table Create and save custom heading style ubns Word 3 08-01-2012 09:42 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:36 PM.


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