<<
Can anyone explain WHY the macro language CAN'T work this way or, if it could be made to do so, why Microsoft has not done it in all these many years while countless ordinary users have struggled with (and posted questions all over the Internet about)
this specific concept?
>>
IMO this is an interesting question, and the trouble is that I don't think anyone really knows whether there is an answer or not.
My first point would be that from a techie perspective, there are two very different things here:
- the macro language ("VBA")
- the "object model" (the things that the developers of Word have chosen to "expose" as objects.
But as usual, problem number one is formulating the questions.
You have provided one example of something that you would like to be able to set up as a repeatable action. But of course, there are many other types of thing that you, or others, might wish to do, and it is in the nature of things that no-one knows in
advance what all those things might be. So already, we could go two ways:
a. how do we define what exactly a Word macro language should be able to do? Even at its simplest, "What questions should the macro language enable you to answer?"
b. if the macro language just had to be able to deal with the example you give, what would it really have to do (in the general case, bearing in mind that a document isn't just a single stream of text, ya da da...)
As far as (a) is concerned, there will always be questions that any macro language cannot answer. For example, suppose we take a question that has been taxing I.T. journalists for decades:-
Journalist: how many words does my document contain?
Macro: What's a "word" ?
Journalist: a sequence of non-blank characters.
Macro: What's a "blank" ?
Journalist: "What do you mean, what's a blank?"
Macro: Is a paragraph mark a blank? Is a Non-joining-oojamaflip a blank?
Journalist: You decide.
Macro: What about headers, footers, other repeated texts?
Journalist: Just count the main text once, and the header/footer text once
Macro: but you have so many headers/footers...
Journalist: Doh! I've been working in English, but now I need that for text in Chinese as well. No spaces there...
In short, the best the macro language can do is to supply you with data about the text, and in a way that means "data as understood by the people who defined the object model". Assembling that data into information that is useful to you is something that
only you can do. (Sorry, I have probably crossed a few "religious" boundaries as to what constitutes "data" and "information" there). Or perhaps it means that you rely on macros constructed by people who have a similar [but not necessarily the same] understanding
of a particular problem as you do.
In which case,
i) where are those macros?
ii) how can you be sure they are the ones that you need?
As for (b), well, first of all, in the general case, I think you still have to think about the question I've put for (a). Beyond that, well, perhaps we could discuss that if you think it is worth your while...