Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
associates76 associates76 is offline
external usenet poster
 
Posts: 1
Default add new section in the report in VBA


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




--
associates76
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default add new section in the report in VBA

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

"associates76" wrote in message
...

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




--
associates76



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms trouble- locking only one section, leaving second section unlocked for text entry KR New Users 2 September 20th 06 03:34 PM
Section 1 should not take section 2 format when section 2 deleted SidewinderQc Page Layout 1 July 25th 06 08:39 AM
show/hide section depending on number of pages in section ivory_kitten Page Layout 7 June 13th 06 11:59 AM
Section Breaks Question: Inserts a Continuous section break - why? Wesley45 Microsoft Word Help 3 November 7th 05 09:40 PM
Merging Report w/o section/page breaks Dana W Mailmerge 0 May 25th 05 03:04 PM


All times are GMT +1. The time now is 08:36 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"