Change Heading 1 Outline Number Programmatically

S

sugarboyrosnerd

Word 2000
Good morning.
I need to change the outline numbering of Heading 1.

This can be accomplished using Word's interface by clicking:
Formt | Bullets and Numbering | Customize | Start At, and then specifying a
starting Heading 1 number.

I need a way to do this programatically ... and here's the rub:
I'm using code that protects my headers and footers. It looks like this:
....
Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
'quit if active doc isn't attached to this template
If ActiveDocument.AttachedTemplate <> ThisDocument Then Exit Sub
'get out of the header/footer if we're in it
Select Case Sel.StoryType
Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
wdFirstPageFooterStory, wdFirstPageHeaderStory, _
wdPrimaryFooterStory, wdPrimaryHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Exit Sub
Case Else
End Select
End Sub

(for the full code see:
http://www.word.mvps.org/FAQs/Customization/ProtectWord2000PlusHeader.htm
– link graciously provided by Doug Robbins)

....
If I try to change the Heading 1 outline numbering using Word's user
interface or try recording a macro of this I receive an "object has been
deleted" error and get yellow highlighting on the "Select Case Sel.StoryType"
line of code above.

How do I avoid getting this error, keep my protected headersfooters and
still change the ouline numbering starting number of Heading 1 style?

Your advice is appreciated.

Thank you,
/Derek
Best wishes from Western Canada
 
S

sugarboyrosnerd

After reading this post again, I realize that I should probably step back a
little.

Here's what I need to do:
The user needs to specify a starting Heading 1 outline number in a userform.
After the user clicks OK, the outline numbering of the first instance Heading
1 in the active document needs to update with the number provided by the
user.
I have created the userform but cannot seem to figure out the correct code
to make this happen.

I can easily do this using Word's interface (Format | Bullets and Numbering
| Customize | Start At), but I am baffled at how to accomplish this with VBA.

Thank you for taking the time to read this.

Best wishes from Western Canada,
/Derek
 
R

Russ

Sugarboyrosnerd,
After reading this post again, I realize that I should probably step back a
little.

Here's what I need to do:
The user needs to specify a starting Heading 1 outline number in a userform.
After the user clicks OK, the outline numbering of the first instance Heading
1 in the active document needs to update with the number provided by the
user.
I have created the userform but cannot seem to figure out the correct code
to make this happen.

I can easily do this using Word's interface (Format | Bullets and Numbering
| Customize | Start At), but I am baffled at how to accomplish this with VBA.
Do you get any useful code when recording a macro while doing this manually
with Word's interface?
 
R

Russ

Sugarboyrosnerd,
Do you get any useful code when recording a macro while doing this manually
with Word's interface?
This subroutine is expecting that you have something selected when you call
it. The 'selection' is passed as an argument to the subroutine.If nothing was selected in the document, then the line above might give you
that error you said you got about "object has been deleted" .
 
S

sugarboyrosnerd

Russ said:
Sugarboyrosnerd,

Hi Russ. Thanks for the response.
Yes, it works great for the section I'm in, but what I really need to do is
iterate through all sections. Word's interface does not provide me with this
code. I've spent weeks trying to figure this out and I'm about ready to give
up.

This subroutine is expecting that you have something selected when you call
it. The 'selection' is passed as an argument to the subroutine.
If nothing was selected in the document, then the line above might give you
that error you said you got about "object has been deleted" .

This makes sense. I can work around this. The code that protects the
header/footer is no longer an issue.
Thanks Russ.
 

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