awan2471
11-01-2014, 06:52 AM
Hi all,
Many thanks in advance on any tips or assistance on how to get started! A VBA newbie here!
I've been struggling with this one for a while, but haven't been able to fine any sample code to get started. Most sources recommend a manual insert of the style separator via Ctrl+Alt+Enter which is extremely tedious for large documents.
Here's the project: I'd like to generate a TOC from inline/run-in headings, but don't want to use linked styles or TC fields. Thus, I'd like to have properly marked paragraphs corresponding to the correct heading style (which are linked up to respective multi-level list levels) with a style separator between the heading text and the paragraph text. The big issue with doing this manually is that insertion of the style separator will mess up the visible numbering of the current list unless you have a second paragraph that is already in list paragraph form. The default for doing this process manually would be to place a new paragraph mark after the first sentence, restyle the second paragraph to list paragraph form since it currently picks up the format from the previous style, then replace cursor on the first paragraph and finally insert the style separator via keyboard shortcut.
The macro would do this:
Remove all current style separators
For each paragraph of header level 1-n
create a second paragraph of list paragraph style starting from the period of the first sentence of each header
insert a style separator at end of first paragraph which would automatically bring the second paragraph up to the first
next
e.g.
1. Heading 1 text[style separator inserted]. This is the list paragraph text that will no longer be picked up by TOC.
2. Heading text only[style separator inserted].
2.1 Sub-heading text[style separator inserted]. More text here.
Many thanks in advance on any tips or assistance on how to get started! A VBA newbie here!
I've been struggling with this one for a while, but haven't been able to fine any sample code to get started. Most sources recommend a manual insert of the style separator via Ctrl+Alt+Enter which is extremely tedious for large documents.
Here's the project: I'd like to generate a TOC from inline/run-in headings, but don't want to use linked styles or TC fields. Thus, I'd like to have properly marked paragraphs corresponding to the correct heading style (which are linked up to respective multi-level list levels) with a style separator between the heading text and the paragraph text. The big issue with doing this manually is that insertion of the style separator will mess up the visible numbering of the current list unless you have a second paragraph that is already in list paragraph form. The default for doing this process manually would be to place a new paragraph mark after the first sentence, restyle the second paragraph to list paragraph form since it currently picks up the format from the previous style, then replace cursor on the first paragraph and finally insert the style separator via keyboard shortcut.
The macro would do this:
Remove all current style separators
For each paragraph of header level 1-n
create a second paragraph of list paragraph style starting from the period of the first sentence of each header
insert a style separator at end of first paragraph which would automatically bring the second paragraph up to the first
next
e.g.
1. Heading 1 text[style separator inserted]. This is the list paragraph text that will no longer be picked up by TOC.
2. Heading text only[style separator inserted].
2.1 Sub-heading text[style separator inserted]. More text here.