View Single Post
 
Old 09-27-2015, 12:09 AM
CodingGuruInTraining CodingGuruInTraining is offline Windows Vista Office 2010 32bit
Novice
 
Join Date: Sep 2015
Posts: 13
CodingGuruInTraining is on a distinguished road
Default

I'm getting an error with this section saying "The requested member of the collection does not exist." When I hover over the i, it says i = 10, if that helps at all.
Code:
If .Cells(i + 4).ColumnIndex = 1 Then
        Set Rng = .Cells(i).Range
        Rng.End = .Cells(i + 4).Range.End
        Rng.Select: Selection.Cells.Merge
End If
I found out why some tables were going off the page; the tables had text wrapping on, which I know can also mess with repeating header rows. I tried adding the code below (after a few attempts) to the With Tbl section, and it centered the table, but when I go to the table properties the text wrapping is still on, which makes the header row not repeat (visually). Oddly enough, one table that had text wrapping on had all the text centered after the macro ran. When I turned text wrapping ON on a different table (just for testing) and ran the macro, neither had centered text.
Code:
    With Tbl
     .Range.Rows.WrapAroundText = False
Sorry I keep forgetting little additions, but I was wondering how you set the vertical and horizontal alignments per column/row. In your previous code I was able to add a part to a Case (as shown below), but I don't see where I can fit this in your current code for specific sections.
Code:
        For i = 5 To .Cells.Count
          Select Case (i Mod 5) + 1
            Case 1: sWdth = InchesToPoints(0.45)
                .Cells().VerticalAlignment = wdCellAlignVerticalTop
I played around with an If/Then situation, but I couldn't get it to work. The bit below runs, but it doesn't do anything and I'd prefer not to go cell by cell.
Code:
      With .Range
        .Cells(1).Select: Selection.Rows.HeadingFormat = True
        For i = 1 To 4
          .Cells(i).Width = InchesToPoints(sWdth(i))
        Next
        ''my addition
        If .Cells.Width = InchesToPoints(0.45) Then
            .Cells().VerticalAlignment = wdCellAlignVerticalTop
        End If
The attached image shows the alignments I'm hoping for. We're so close!
Attached Files
File Type: docx Table Template.docx (14.6 KB, 9 views)
Reply With Quote