View Single Post
 
Old 03-20-2014, 06:53 AM
kennethc kennethc is offline Windows XP Office 2003
Novice
 
Join Date: Sep 2010
Posts: 23
kennethc is on a distinguished road
Default 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
Reply With Quote