View Single Post
 
Old 11-10-2015, 02:52 PM
snufse snufse is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2015
Posts: 1
snufse is on a distinguished road
Default Inserting a table using ADD command

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
Reply With Quote