View Single Post
 
Old 12-08-2016, 02:28 AM
slaycock slaycock is offline Windows 7 64bit Office 2013
Expert
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

The entertainment continues.

I tested your code on my Surface Pro 4 last night (Windows 10 64 bit, Office 2016) and made the observations above.

I tested the code on my work laptop this morning it works fine but still puts the canvas above the table.

I rejigged the code and came across another 'anomaly'. The code below falls over at the .cells(2) statement with a 'The requested member of the collection is not found' error.

Code:
         With .Tables(.Tables.count)
            .AllowAutoFit = False
            .BottomPadding = 3
            .TopPadding = 3
            .LeftPadding = 6
            .RightPadding = 6
            .PreferredWidth = CentimetersToPoints(15.5)
            .Style = ActiveDocument.Styles("Table Grid")
            With .Range.Tables(1).Range
               .InsertCaption label:="Table", Position:=wdCaptionPositionAbove, Title:=":" & vbTab & "Add table caption text"
               .Cells.VerticalAlignment = wdCellAlignVerticalCenter
               .Cells(1).Range.Text = "Table Text test 2 + local effect: bold"
               .Cells(1).Range.Font.Bold = True
               .Cells(2).Range.Text = "Table text + local effect: Align left"
               .Cells(4).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
               .Cells(5).Range.Text = "Table Text is centered by default"
               .InsertCaption label:="Table", Position:=wdCaptionPositionAbove, Title:=":" & vbTab & "Add table caption text"
            End With
However if I move the .insertcaption statement to after the .cells statements it works fine.

In the former case using select instead of the cells(2) statement the selected region includes the caption above the table.

Methinks something is not right.
Reply With Quote