Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Change Heading 1 Outline Number Programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sugarboyrosnerd - 26 Sep 2006 16:06 GMT
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
sugarboyrosnerd - 27 Sep 2006 20:36 GMT
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

> Word 2000
> Good morning.
[quoted text clipped - 39 lines]
> /Derek
> Best wishes from Western Canada
Russ - 15 Oct 2006 05:36 GMT
Sugarboyrosnerd,

> After reading this post again, I realize that I should probably step back a
> little.
[quoted text clipped - 9 lines]
> 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?

> Thank you for taking the time to read this.
>
[quoted text clipped - 44 lines]
>> /Derek
>> Best wishes from Western Canada

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Russ - 15 Oct 2006 05:51 GMT
Sugarboyrosnerd,

>> After reading this post again, I realize that I should probably step back a
>> little.
[quoted text clipped - 29 lines]
>>> ...
>>> Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
This subroutine is expecting that you have something selected when you call
it. The 'selection' is passed as an argument to the subroutine.
>>>     '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
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" .
>>>     Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
>>>                wdFirstPageFooterStory, wdFirstPageHeaderStory, _
[quoted text clipped - 24 lines]
>>> /Derek
>>> Best wishes from Western Canada

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

sugarboyrosnerd - 18 Oct 2006 02:00 GMT
> Sugarboyrosnerd,
> >
[quoted text clipped - 13 lines]
> > Do you get any useful code when recording a macro while doing this manually
> > with Word's interface?

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.

> >> Thank you for taking the time to read this.
> >>
[quoted text clipped - 21 lines]
> 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.

> >>>     Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
> >>>                wdFirstPageFooterStory, wdFirstPageHeaderStory, _
[quoted text clipped - 24 lines]
> >>> /Derek
> >>> Best wishes from Western Canada

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.