In MS Word VBA, what is the unit of measure "Story" and where does it fit into the hierarchy of units in a Word document?
This reference only says that wdUnits.wdStory
refers to "a story" which is not helpful. I couldn't find any other references that explain what I'm looking for.
1a : an account of incidents or events. b : a statement regarding the facts pertinent to a situation in question. c : anecdote especially : an amusing one. 2a : a fictional narrative shorter than a novel specifically : short story. b : the intrigue or plot of a narrative or dramatic work.
A story is the telling of an event, either true or fictional, in such a way that the listener experiences or learns something just by the fact that he heard the story. A story is a means of transferring information, experience, attitude or point of view. Every story has a teller and a listener.
Definition of true story : an account of something that really happened.
The best story is a well-told tale about something the reader feels is relevant or significant. The best stories are more complete and more comprehensive. They contain more verified information from more sources with more viewpoints and expertise. They exhibit more enterprise, more reportorial effort.
This is actually a more complicated question than most would think. In a Microsoft Word blog post stories are defined as:
"...distinct regions of content that make up a Word document and share properties and functionality. Put differently, behind the scenes, Word breaks all documents up into a collection of chunks with shared properties and functionality. Officially, these are called stories."
These chunks can be comments, endnotes, footnotes, footers, headers, etc.
Later on the blog post states:
"...all stories in a document utilize a common set of properties that determine the presentation of the contents within each story. These shared properties include font information, style definitions, numbering definitions, and document settings."
For more information, please see the full Microsoft blog post:
Behind the Curtain: Stories in Word
UPDATE
@WaiHaLee has brought to my attention that the Microsoft blog post I link to in my original answer is no longer available. Because of this, I will elaborate further on what a Story is in the Word Object Model.
As of this writing there are 17 types of Stories, as this screen capture from the Object Browser of the Word VBA IDE shows:
Each of these allows a specific region of content within a Word document to be affected programmatically, often via the StoryRanges
collection.
Allen Wyatt has written a very good article entitled
Including Headers and Footers when Selecting All
wherein he explains some different methods for using StoryRanges
. For example, one can update fields in only the Primary Footer area of a document:
ActiveDocument.StoryRanges(wdPrimaryFooterStory).Fields.Update
StoryRanges
can also be used to search particular areas of a document as detailed in
Using a macro to replace text where ever it appears in a document
So in short, the StoryRanges
collection allows a programmer to affect all or some of the unique parts of a Word Document. Each part is a Range enumerated as a StoryType
. And each StoryType
is what is meant as a Story within Word.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With