Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 05-01-2018, 06:04 AM
gmaxey gmaxey is offline Table of Contents causes error when checking style Windows 7 32bit Table of Contents causes error when checking style Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Or why don't you let Word use it own will to create the TOC and then use your will (aka macro) to make a table out of the TOC:

Code:
Sub ScratchMacro()
Dim oRng As Range
Dim oTbl As Table
  Set oRng = Selection.Fields.Add(Selection.Range, wdFieldTOC).Result
  oRng.Fields(1).Unlink
  Set oTbl = oRng.ConvertToTable(vbTab)
  With oTbl
    .Rows.Add BeforeRow:=oTbl.Rows(1)
    .Cell(1, 1).Range.Text = "Topic"
    .Cell(1, 2).Range.Text = "See Page"
    .Columns(2).Select
    Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
    .Borders.OutsideLineStyle = wdLineStyleSingle
  End With
  oRng.Select
  Selection.Collapse wdCollapseEnd
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of Contents causes error when checking style Table of contents vs headings: what style settings need to be changed? boxhamster Word 5 08-15-2015 03:25 PM
LaTeX style table of contents in MS Word MichaelHenrotte Word 1 11-23-2014 03:16 AM
Table of Contents causes error when checking style Creating Table of Contents From a Custom Style Jetheat Word 4 12-15-2013 03:54 PM
How to have this Heading – Table of contents style? Jamal NUMAN Word 0 01-13-2011 06:02 PM
Word 2003 Table of Contents Error Message ktcolburn Word 1 10-30-2005 06:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:37 PM.


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