I have a word template where I added a table to Quick Parts / Part Gallery. I also added a command button with code behind. Now when I click the ADD button it inserts a new table in the form and that is what I want. When it display the inserted table it also gives an error:
Table Error! No text of specified style in document.‑1 <Table Title>
Not sure what this is and how to correct. Thank you.
Code behind the ADD button:
Code:
Private Sub CommandButton1_Click()
With CaptionLabels("Table")
.NumberStyle = wdCaptionNumberStyleArabic
.IncludeChapterNumber = True
.ChapterStyleLevel = 1
.Separator = wdSeparatorHyphen
End With
Selection.InsertCaption Label:="Table", TitleAutoText:="", Title:="", _
Position:=wdCaptionPositionAbove, ExcludeLabel:=0
Selection.TypeText Text:=" <Table Title>"
Selection.TypeParagraph
ActiveDocument.AttachedTemplate.BuildingBlockEntries("corporate_table" _
).Insert Where:=Selection.Range, RichText:=True
End Sub