#1
|
|||
|
|||
Error when using customised button
I have a customised button in Word 2010 and when you click on it, you get a list of options. One of those is to insert a table of contents. I have created this using Custom UI Editor, as follows: <button id="rxbtnStylesInsertTOC" label="Insert TOC" showLabel="false" image="TOC" supertip="Insert TOC at the current location in the document." onAction="plctoc"/> The callback is as follows: 'Callback for rxbtnStylesInsertTOC onAction Sub plctoc(control As IRibbonControl) End Sub I recorded the macro and the code is as follows: Sub plctoc() ' ' plctoc Macro ' ' With ActiveDocument .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _ True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _ LowerHeadingLevel:=1, IncludePageNumbers:=True, AddedStyles:="", _ UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _ True .TablesOfContents(1).TabLeader = wdTabLeaderSpaces .TablesOfContents.Format = wdIndexIndent End With End Sub When I click on the button to run the insert table of contents I get the following error: "Wrong number of arguments or invalid property assignment" What am I missing or where have I fallen short, all suggestions greatly received. Many thanks. Kenneth |
#2
|
|||
|
|||
Could you possibly attach (in a zip folder) the .dotm or .docm file with your customization and macro? Click (in this forum) on the Go Advanced button under the reply window.
Why not simply use the Insert Table of Contents command from Word commands rather than a macro? OK, I see, you just want level 1 headings. I get an error message in the Custom UI when checking. May just be my typing. |
#3
|
|||
|
|||
Zipped template
Here you go, hopefully this helps?
Thanks. Kenneth |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convert customised endnotes to automatic | amnew | Word | 6 | 06-04-2013 11:47 PM |
Deploying customised toolbars | kennethc | Word | 1 | 02-11-2012 01:18 PM |
Project 2010 Customised Lookup Fields | OTPM | Project | 0 | 07-26-2011 11:10 AM |
Customised style set | Sonja | Word | 3 | 05-09-2011 03:30 PM |
Mail merge with customised subject | mohanss | Mail Merge | 0 | 06-26-2010 10:14 AM |