Hey,
Given this code, in Outlook 2010 (is fine in 2016!?) why would it error out on the lines setting the PreferredWidth of each column:
The error is "5992: Cannot access individual columns in this collection because the table has mixed cell widths." I understand this to be because there are merged cells, but there aren't any in my table - it's a brand new table each time.
The exact same code seems to work OK directly in Word VBA editor.
Thanks
Given this code, in Outlook 2010 (is fine in 2016!?) why would it error out on the lines setting the PreferredWidth of each column:
Code:
...
...
Set Selection = Inspector.WordEditor.Application.Selection
With Selection
If .Tables.Count < 1 Then
Set Table = .Tables.Add(Range:=.Range, NumRows:=1, NumColumns:=4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
.InsertRows NumRows:=FileCount
With Table
.Style = "Table Grid"
.PreferredWidthType = wdPreferredWidthPoints
.PreferredWidth = 700
.TopPadding = CentimetersToPoints(0.12)
.BottomPadding = CentimetersToPoints(0.12)
.Columns.PreferredWidthType = wdPreferredWidthPoints
----> .Columns(1).PreferredWidth = 30 <----
----> .Columns(2).PreferredWidth = 470 <----
----> .Columns(3).PreferredWidth = 90 <----
----> .Columns(4).PreferredWidth = 110 <----
With .Borders
.Enable = True
.OutsideColor = 5263440
.InsideColor = 5263440
End With
With .Rows.First
.HeadingFormat = True
.Height = 20
.Shading.BackgroundPatternColor = ColorPicker()
.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.Cells(1).Range.Text = "No."
.Cells(2).Range.Text = "Name"
.Cells(3).Range.Text = "Size"
.Cells(4).Range.Text = "Expiry Date"
With .Range
.Font.Color = 16777215
.Font.Size = 12
End With
End With
End With
Else
Set Table = .Tables(1)
.InsertRows NumRows:=FileCount
End If
End With
...
...
The error is "5992: Cannot access individual columns in this collection because the table has mixed cell widths." I understand this to be because there are merged cells, but there aren't any in my table - it's a brand new table each time.
The exact same code seems to work OK directly in Word VBA editor.
Thanks