(Msg. 1) Posted: Sat Dec 13, 2008 1:15 pm
Post subject: Build TOC Archived from groups: microsoft>public>word>vba>userforms (more info?)
I have some requirements to build TOCs using strictly TC fields (no styles).
I can do that easy enough by clicking on the InsertTOCdialog, clicking on
Options, and changing the Build table of contents from options 1. Uncheck
"Styles" 2. Uncheck "Outline levels" and 3. Check "table entry fields"
I want to do this programmatically. I have figured out how to uncheck
"Outline levels" and how to check "table field entries" but can find no way
to uncheck "Styles"
Sub InsertManualTOC()
Dim i As Long
Dim myArray() As String
With Dialogs(wdDialogInsertTableOfContents)
.UseOutlineLevel = 0
.Fields = 1
.Show
End With
End Sub
(Msg. 2) Posted: Sun Dec 14, 2008 10:46 am
Post subject: Re: Build TOC [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
How about
With Selection.Fields
.Add Selection.Range, wdFieldTOC, "\f \h \z", False
.Update
End With
ActiveWindow.View.ShowFieldCodes = False
?
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
Greg Maxey wrote:
> I have some requirements to build TOCs using strictly TC fields (no
> styles).
> I can do that easy enough by clicking on the InsertTOCdialog,
> clicking on Options, and changing the Build table of contents from
> options 1. Uncheck "Styles" 2. Uncheck "Outline levels" and 3.
> Check "table entry fields"
> I want to do this programmatically. I have figured out how to uncheck
> "Outline levels" and how to check "table field entries" but can find
> no way to uncheck "Styles"
>
> Sub InsertManualTOC()
> Dim i As Long
> Dim myArray() As String
> With Dialogs(wdDialogInsertTableOfContents)
> .UseOutlineLevel = 0
> .Fields = 1
> .Show
> End With
> End Sub
>
>
> Anyone have any ideas?
>
> Thanks.
(Msg. 3) Posted: Sun Dec 14, 2008 10:46 am
Post subject: Re: Build TOC [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Graham,
Yes that works, thanks.
The root question, I suppose, is if your can preset the TOC options "Use
Outlining levels" and "Table entry fields" using VBA code:
Sub InsertManualTOC()
With Dialogs(wdDialogInsertTableOfContents)
.UseOutlineLevel = 0
.Fields = 1
.Show
End With
End Sub
Why can't you preset the "Styles" options. Sometimes I have a need to
build TOCs from a combination of styles and TC fields and sometimes I need
to build a TOC with just TC fields. The current behaviour of the TOC
Options dialog is "Styles" and "Use outline level" are preset to "checked"
and these value stick. Each time I want to create a TOC with a combination
of styles and fields I have to change the options but they won't stick. I
wanted to create a macro that opens the dialog with the Styles and fields
preset to "checked" and anther macro that opens the dialog with just fields
checked.
"Graham Mayor" <gmayor DeleteThis @REMOVETHISmvps.org> wrote in message
news:uGtHDicXJHA.5764@TK2MSFTNGP04.phx.gbl...
> How about
>
> With Selection.Fields
> .Add Selection.Range, wdFieldTOC, "\f \h \z", False
> .Update
> End With
> ActiveWindow.View.ShowFieldCodes = False
>
> ?
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> Greg Maxey wrote:
>> I have some requirements to build TOCs using strictly TC fields (no
>> styles).
>> I can do that easy enough by clicking on the InsertTOCdialog,
>> clicking on Options, and changing the Build table of contents from
>> options 1. Uncheck "Styles" 2. Uncheck "Outline levels" and 3.
>> Check "table entry fields"
>> I want to do this programmatically. I have figured out how to uncheck
>> "Outline levels" and how to check "table field entries" but can find
>> no way to uncheck "Styles"
>>
>> Sub InsertManualTOC()
>> With Dialogs(wdDialogInsertTableOfContents)
>> .UseOutlineLevel = 0
>> .Fields = 1
>> .Show
>> End With
>> End Sub
>>
>>
>> Anyone have any ideas?
>>
>> Thanks.
>
>
(Msg. 4) Posted: Sun Dec 14, 2008 5:26 pm
Post subject: Re: Build TOC [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
The short answer is that I don't know - it is much the same inserting form
fields and setting the parameters with vba to (say) a date format.
However for TOC basically all you have is a TOC field with an assortment of
switches. You can add those switches, if you know what they are (and they
are easy enough to establish by inserting the field from the insert > field
command) in the text segment of the Field.Add command - as in the example I
suggested.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
Greg Maxey wrote:
> Graham,
>
> Yes that works, thanks.
>
> The root question, I suppose, is if your can preset the TOC options
> "Use Outlining levels" and "Table entry fields" using VBA code:
>
> Sub InsertManualTOC()
> With Dialogs(wdDialogInsertTableOfContents)
> .UseOutlineLevel = 0
> .Fields = 1
> .Show
> End With
> End Sub
>
> Why can't you preset the "Styles" options. Sometimes I have a need
> to build TOCs from a combination of styles and TC fields and
> sometimes I need to build a TOC with just TC fields. The current
> behaviour of the TOC Options dialog is "Styles" and "Use outline
> level" are preset to "checked" and these value stick. Each time I
> want to create a TOC with a combination of styles and fields I have
> to change the options but they won't stick. I wanted to create a
> macro that opens the dialog with the Styles and fields preset to
> "checked" and anther macro that opens the dialog with just fields
> checked.
> Can't find a way >
>
>
>
> "Graham Mayor" <gmayor DeleteThis @REMOVETHISmvps.org> wrote in message
> news:uGtHDicXJHA.5764@TK2MSFTNGP04.phx.gbl...
>> How about
>>
>> With Selection.Fields
>> .Add Selection.Range, wdFieldTOC, "\f \h \z", False
>> .Update
>> End With
>> ActiveWindow.View.ShowFieldCodes = False
>>
>> ?
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> Greg Maxey wrote:
>>> I have some requirements to build TOCs using strictly TC fields (no
>>> styles).
>>> I can do that easy enough by clicking on the InsertTOCdialog,
>>> clicking on Options, and changing the Build table of contents from
>>> options 1. Uncheck "Styles" 2. Uncheck "Outline levels" and 3.
>>> Check "table entry fields"
>>> I want to do this programmatically. I have figured out how to
>>> uncheck "Outline levels" and how to check "table field entries" but
>>> can find no way to uncheck "Styles"
>>>
>>> Sub InsertManualTOC()
>>> With Dialogs(wdDialogInsertTableOfContents)
>>> .UseOutlineLevel = 0
>>> .Fields = 1
>>> .Show
>>> End With
>>> End Sub
>>>
>>>
>>> Anyone have any ideas?
>>>
>>> Thanks.
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum