Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2015, 02:52 PM
snufse snufse is offline Inserting a table using ADD command Windows 7 64bit Inserting a table using ADD command Office 2013
Novice
Inserting a table using ADD command
 
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
  #2  
Old 11-10-2015, 03:28 PM
gmaxey gmaxey is offline Inserting a table using ADD command Windows 7 32bit Inserting a table using ADD command Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Toggle field codes in your document after you run the code. There error is due to the StyleRef 1. You probably don't have any Heading 1 style applied in your document that is linked to a Level using a Multilevel list.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a table using ADD command Inserting Images/Pictures into Table of Content Simon Word 11 09-12-2016 11:37 PM
Inserting a table using ADD command Inserting arrow images into a table jklein Word Tables 5 06-29-2014 07:40 PM
Inserting a table using ADD command Inserting table natasha_arriell Mail Merge 4 06-04-2014 12:13 AM
Inserting a table using ADD command Inserting landscape Table into Portrait Document sstark Word Tables 2 02-13-2013 08:43 AM
Inserting a table Katelyn Outlook 0 04-05-2012 09:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft