add new section in the report in VBA

A

associates76

Hi,

I was wondering if i could get some help here.

What i have been trying to achieve here is to make it easier for our
staff to write up a report document for their client. Because so far we
have a lot of inconsistencies among our staff's reports. One may use a
different style or font size and so on. So i was asked to write a
program in word VBA to mitigate the problem.
I decided to use autotext (for it's easier than programming it from
scratch). and it works really fine.

The report consists of as follows in that order
Covering page
TOC
Executive summary (optional)
Sections
Bibliography (optional)
Glossary (optional)
Appendixes (optional)

Now, so far, the autotext only put in Section 1 to the page to start
with. User might want to be able to add new Sections in the section of
the report later on. so i created a macro called "insert section". When
user clicks on
"add new section button", he/she is prompted for the HEADING. As soon
as he hits the "OK" button, it should insert a new page break as well
as putting
whatever the next Section number to that new page.

This is what it looks like in the section.
Section 1. HEADING

so, when user clicks on "insert section" button. it should do the
following
Section 1. HEADING

----------section break(next page)-------------
Section 2. HEADING2

and so on

The problem i'm having with the code described below is
Section 1. HEADING

----------section break(next page)--------------
Section 1. HEADING2

There is no continuous flow here. It should show Section 2., not
Section 1.

this is the code i've got so far.
Sub InsertNewSection()
Selection.InsertBreak Type:=wdSectionBreakOddPage
Selection.Style = ActiveDocument.Styles("Section Heading 1")

Selection.Range.ListFormat.ApplyListTemplate
ListTemplate:=ListGalleries( _
wdOutlineNumberGallery).ListTemplates(7),
ContinuePreviousList:=True, _
ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _
wdWord10ListBehavior

Selection.TypeText Text:=InputBox("Please enter the section
heading:",
"Enter Section Heading")
Selection.TypeParagraph
End Sub

I really need your assistance on this. For i have spent too much on
this but no luck.

Thank you in advance
 
D

Doug Robbins - Word MVP

I assume you are the same person who started a thread that is on a subject
very similar to this in vba.general newsgroup. If that is correct, it would
be far better if you continued with that thread, to which I posted a
response to the latest issue that you raised.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top