View Single Post
Old 02-24-2017, 02:46 AM
lodi123 lodi123 is offline Windows 7 32bit Office 2010 32bit
Join Date: Feb 2017
Posts: 10
lodi123 is on a distinguished road
Default Problem with table grid when selecting status in ribbon


I'm stuck with another problem. I hope you can help me!
So in my document I have a table with help text that says to select the right status (3 choices) in the custom ribbon.
In most cases, when selecting a status, this table disappears and the choosen status appears in a new table.
In some cases, I get an error message that says the fault lies with the Style = Table Grid.
Everytime I get this error, my Word window also says Compatibility Mode, even though it's the same Word version as in the non-error case.
Is this because in the compatibility mode, there is no such style as table grid?

Sub ApplyStandardWorkflow(Control As IRibbonControl)
With ActiveDocument
Dim oRng As Range

Set oRng = ActiveDocument.Tables(2).Rows(1).Cells(1).Range
oRng.End = oRng.End - 1 'to exclude the end of cell marker
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False

End With

ActiveDocument.AttachedTemplate.BuildingBlockEntri es("StandardWorkflow").Insert _
Where:=Selection.Range, RichText:=True
Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
End With
End Sub

Thank you!!
Reply With Quote