Re: StoryRanges collection
From: Chad DeMeyer (cjdemeye)
Date: 08/25/04
- Next message: Doug Robbins: "Re: How to Lock links (programatically) without incurring an update"
- Previous message: JSM: "Re: Conditional Compilation question"
- In reply to: Jay Freedman: "Re: StoryRanges collection"
- Next in thread: Chuck: "Re: StoryRanges collection"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Aug 2004 16:24:53 -0700
Thank you to Doug, Jezebel, Peter, and Jay for your thoughts on this topic.
I think I understand Jezebel's and Peter's points, but I still believe that
this part of the Word object model could have and should have been
constructed differently. How much time and frustration was spent by the
programmer(s) who developed the For Each with nested Do Loop kludge? :>}
Regards,
Chad
"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:kobli0pqh6pa6hic4bcgkm7cr5amag9hee@4ax.com...
> Hi Chad,
>
> You've hit one of the perennial sore spots -- feels like an abscessed
> tooth by now. :-(
>
> There are a fair number of things in the object model that range from
> inconvenient through illogical to incomprehensible (not to mention the
> things that simply aren't implemented). The sticky part is that many
> of these things have become "standard" -- if MS fixed them, tons of
> existing VBA code would break. I don't like it, but I can see their
> point.
>
> We've repeatedly requested that Find/Replace and Update Fields, when
> invoked on ActiveDocument.Range, should affect all parts of the
> document. It hasn't happened yet...
>
> --
> Regards,
> Jay Freedman http://aspnet2.com/mvp.ashx?JayFreedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>
> "Chad DeMeyer" <cjdemeye at bechtel dot com> wrote:
>
> >Thanks, Doug
> >I now understand what it is working around, but I'm forced to conclude
that
> >there IS a problem with the StoryRanges collection - each member returns
a
> >single contiguous range even though multiple non-contiguous ranges may be
> >contained within the StoryRange. So we work around that by...returning
the
> >non-contiguous ranges with the same property (.StoryRanges)? This is,
IMHO,
> >a major weakness in the Word object model. They should have defined a
> >separate collection of the different ranges within a story, something
like
> >StorySubRanges, then it would have been clearer and more intuitive to
access
> >each range in the document.
> >
> >Regards,
> >Chad
> >
> >
> >"Doug Robbins" <dkr@NOmvpsSPAM.org> wrote in message
> >news:eeQNIMWiEHA.704@TK2MSFTNGP12.phx.gbl...
> >> Hi Chad,
> >>
> >> I think that we explain it in the article "Using a macro to replace
text
> >> where ever it appears in a document
> >> including Headers, Footers, Textboxes, etc." at:
> >>
> >> http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm
> >>
> >>
> >> --
> >> Please respond to the Newsgroup for the benefit of others who may be
> >> interested. Questions sent directly to me will only be answered on a
> >paid
> >> consulting basis.
> >>
> >> Hope this helps,
> >> Doug Robbins - Word MVP
> >> "Chad DeMeyer" <> wrote in message
> >> news:ewuHsGWiEHA.632@TK2MSFTNGP12.phx.gbl...
> >> >I have seen numerous posts on the functional method for updating all
> >fields
> >> > in a document:
> >> >
> >> > Dim oRange As Range
> >> > For Each oRange In ActiveDocument.StoryRanges
> >> > Do
> >> > oRange.Fields.Update
> >> > Set oRange = oRange.NextStoryRange
> >> > Loop Until oRange Is Nothing
> >> > Next
> >> >
> >> > What I haven't seen is an explanation of why this method is
necessary.
> >Is
> >> > there something wrong with the StoryRanges collection? Normally, a
For
> >> > Each
> >> > construct would suffice to loop through the members of a collection,
so
> >> > why
> >> > with StoryRanges is it necessary to also loop through the collection
> >using
> >> > the NextStoryRange method until its return is Nothing? Furthermore,
it
> >> > seems like the code above should update the fields in each StoryRange
> >> > multiple times, the number of times being equal to the number of
> >> > StoryRanges
> >> > in the document.
> >> >
> >> > Hoping somebody can fill in the blanks.
> >> > Regards,
> >> > Chad
> >> >
> >> >
> >>
> >>
> >
>
- Next message: Doug Robbins: "Re: How to Lock links (programatically) without incurring an update"
- Previous message: JSM: "Re: Conditional Compilation question"
- In reply to: Jay Freedman: "Re: StoryRanges collection"
- Next in thread: Chuck: "Re: StoryRanges collection"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|