It must be one of the most asked questions about macros - why has it not been addressed in the macro language after all these years?

Anonymous
2013-02-19T05:49:37+00:00

To those of us who are just users and not programmers, it seems like MS Word "macros" -- particularly recorded macros -- ought to include the capability to be easily constructed to (1) go to some identifiable place in a document and "do" some things starting from that point (such as "find" a new paragraph immediately followed by the word "publish", then go to the end of that line of text and insert "**") and then (here comes the sticking point) (2) repeat that series of activities over and over UNTIL some identifiable point is reached in the document [e.g., the end of the page; the end of the document; the end of the paragraph]. 

But for some reason, Word macros cannot be made to do that in an "easy for non-programmers to understand" sort of way.  I've had it explained to me several times that I must use references to "ranges" and/or "counts" and all sorts of other commands that seem overly complicated to just "go to a place and do this", then go to the next such place, and do the same thing", and keep doing that UNTIL . . .  It's certainly nothing that can be accomplished by recording a macro (as it logically should be.)   With help, I'll finally get a macro cobbled together to do what I need done.  But when the next occasion to do something like that comes along -- maybe a year later -- I've forgotten all those inscrutable concepts and I once again find myself just needing to record a macro doing some set of activities and then have it repeat itself through the document.

I know it's easy for programmers to understand all these arcane requirements to be able to get a macro to work through a document that way, but a lot of us "out here" are just regular users who occasionally need to be able to do repetitive tasks within a particular document and believe it should be easier to accomplish this sort of thing than it appears the macro language permits. 

Can someone explain why the macro language cannot be made to easily allow a macro to just do something like: 

   DO         [find <text>, then move from there to another point 8 characters away and then make some change to the text at that point], then     LOOP (DOing that same series of things again} UNTIL [the End of the Page or the End of the Document is reached], then just Stop the macro from further executing.

I'm sure I haven't used the right syntax above, but I hope you get the point - it ought to be just that simple to accomplish that sort of chore, but it isn't. 

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?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2013-02-24T17:37:41+00:00

D PaulDalton,

Glad I could help and I understand your comments and concerns. 

Unfortunately, I don't know if your suggestions will ever get any traction even if they made it to the "right person.  In line with what Jay and Peter have said, my experience is that VBA becomes less and less complete as Word progresses rather than more and more complete.  For example, everything that you could do as a user with a drawing or shape object in Word 2003, you could do with VBA.  With the new graphics engine introduced with Word 2010, there are many things that a user can do that now cannot be done with VBA.  Most of the things that you can do with those graphics are not even recorded.  I suspect that the recorder will go away before it becomes anything like you envision.  Still, it is a good and valid vision.

Good luck.

Was this answer helpful?

0 comments No comments
Answer accepted by question author
Anonymous
2013-02-22T17:33:28+00:00

I have a few observations, and that's probably about all I'll be able to contribute here.

In order to get much further with getting Microsoft to do this, you'll need to get your idea onto their agenda. While it's possible that ideas posted here sometimes get some attention from them, you can't guarantee it: you aren't really dealing with Microsoft people (it's mostly volunteers), and certainly not the Microsoft product group people, in here. So you either need to know someone, or find a proxy (either someone close or perhaps an influential corporate that can see the value of the idea). As for timing, I don't know what their product cycle looks like now, either - it could well be changing rapidly as their Office 365 subscription service develops. But if it's the old cycle, I would guess they already have the outline if not most of the details for the version after 2013 and may be thinking about ideas after that. Also, I would be very surprised if they did not want to be absolutely sure of their ground as far as Intellectual Property is concerned.

On the technical front, the biggest technical questions for me are "what can be done in the 'DO' part of the feature?" (i.e. the one you described a few messages back)

If it's "execution of an arbitrary macro", then it can do anything VBA can do, form "something sensible" to "accidentally trash every file on the system." It can also contain infinite loops, code that results in untrappable errors - at least not trappable by VBA - and doubtless other things I haven't even thought about that may result in dismay for the user.

As long as the user is willing to take responsibility for their part of the code, I don't see any technical showstoppers*.* But that doesn't mean that such problems won't turn up.

From a support perspective though, having a half-and-half feature like that is a bit of a liability, to say the least.

Going to a slightly more detailed level, when I read your earlier messages, I got the impression that you were keen to avoid the more techie stuff involving selections, ranges etc. The trouble is that if the user still has to write VBA, e.g. to find something then move a few words to the right or whatever, they still have to understand that stuff. What's more, in the general case some code will function in (say) a paragraph in the main body of the document, but fail in a footer (say). In other words, in many cases the user would need to understand even more about their code.

When I first read your question, I had a slightly different idea as to what you were driving at. To me, how you avoid dealing with "allowing any piece of VBA" is to try to identify a small but potent set of things the user might want to do (obviously reducing the generality obtainable in VBA) and allow them to do those things and nothing else. That's one of the reasons I suggested that a change to the recorder might be needed - you'd only be able to record the things that the feature is designed to allow. Then the feature takes responsibility for making all that stuff happen. How to do that technically is a detail, but perhaps specify that the DO macro only contains calls to a number of predefined subs/functions that have been designed to behave well within the overall structure of the feature. Or define a completely new, small, non-VBA language and some VBA to interpret it.

Finally, I know we have been taking about Word and VBA. But really, we're talking about providing a set of features for repetitive processing. The Web App version of Word doesn't have any of that stuff, and perhaps it is intended that it never will. But because it doesn't have VBA, it would I think benefit far more from a feature to let its users do something like "do this in every paragraph that begins with 'Jack Robinson'"

Was this answer helpful?

0 comments No comments

39 additional answers

Sort by: Oldest
  1. Anonymous
    2013-02-20T17:38:18+00:00

    "What, exactly, is MS supposed to do to make the use of loops simpler for someone who lacks the inclination to learn???" 

    The presumption that a Word user who does not adequately understand programming concepts "lacks the inclination to learn" is erroneous.  That's like saying a driver could be presented with a car that drives only straight down the road and, if he wants to be able to make that car turn left or right, he should have the "inclination" -- and take the time --  to learn how to build and add a steering mechanism to it.  Though I suspect that, with enough time, many of us could figure out how to build and incorporate such a steering mechanism into a car, most of us really just want to be able to drive a car that has an effective steering mechanism already built into it. 

    And that's how I feel about the macro facility in MS products.  It's capabilities should be made more accessible to ordinary users. 

    So, to try to be responsive to the non-derogatory portion of your question ("What, exactly, is MS supposed to do to make the use of loops simpler"), here are some thoughts:

    • As it exists now (for non-programmer users), the macro facility in Word (and Excel, etc.) exists as one of two extremes:  Too limited (Macro Recording) and too complex (the raw and somewhat arcane VBA programming language).  The macro facility provides no "in-between" tools, and (in the absence of some sort of technical prohibition beyond "it would be a lot of work for us to do that") that macro facility really should be made more useful for non-programmers.
    • Microsoft should conduct user research to identify a list of more complex functionality (beyond the capabilities of simple Macro Recording) that "non-programer" users of Word would like to  be able to use to more easily cause their "simple" macros to be more effective (such as performing the looping or repetitive functionality that I identified; but I'm sure there are many, many other such functionality sets that could be "standardized."  As an MVP who presumably deals with a lot of user questions about macros, I suspect you alone could probably come up with at least 5-10 such items -- just imagine how many might be identified by MS' focusing on the issue).
    • Decide which of these functionality sets can be programmed into generic Macro Options, then create and compile these "Options" in a manner that imposes on each a standardized set of assumptions about the myriad variables a trained programmer would take into account (essentially, program the Option such that, by adding it to the existing macro, nothing is going to get "found" or "changed" other than as is expressly described in the macro to which this Option is applied).
    • Include adequate operational explanations/caveats, perhaps as ToolTips, or perhaps with "Do You Want to Proceed (Y/N?)" requirements (e.g.[if it were the Option to apply my looping/repeating functionality request], "selecting this Option will cause the affected macro to execute throughout the current [document, paragraph, section, page, etc., as selected].  Note that unanticipated conditions, such as ( ???? - though, if it can be listed, it seems like it could be anticipated in the programming), may cause unexpected or incomplete results.  Be sure to carefully review the result to be sure that what you intended was accomplished.  If not, modification of the macro using VBA may be required."
    • Make these Macro Options available to users as functionality choices that can be automatically (added to/imposed upon/wrapped around) the user's own simple macro, including of course those created using the Macro Recorder.  One way this might be done would be to add to the dialog from which macros now are selected to be edited a "Macro Options" button, selection of which would produce a list of available Macro Options available to be applied to the highlighted macro.

    So, the above are my thoughts about what MS could do to improve the macro facility, including specifically how they could "make the use of loops simpler." 

    By doing something like this, I believe MS could make the macro capability within Word (as well as in other apps that use VBA macros) far more accessible, efficient, and useful to ordinary (non-programmer) users.  That sort of functional improvement to the macro capability in these applications would be an infinitely more valuable and useful product improvement than the cosmetic changes that seem to have been the "product enhancements" made in the past several version changes.  

    Now, if you happen to know of a way to bring these thoughts to the attention of someone at Microsoft who would be in a position to both recognize the value of doing this sort of thing and to cause it to be seriously considered, I -- and I suspect many others -- would greatly appreciate your doing so.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-02-20T21:02:44+00:00

    <<

    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:

    1. the macro language ("VBA")
    2. 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...

    Was this answer helpful?

    0 comments No comments
  3. Jay Freedman 208.3K Reputation points Volunteer Moderator
    2013-02-20T22:03:17+00:00

    Peter has addressed some (and by no means all) of the technical issues involved in the "Why" question. Beyond that, there is a constellation of commercial issues:

    • What is the business case for doing the work necessary to make the product(s) behave as requested? At the most basic, how much more revenue can Microsoft achieve by providing this function, compared to what it will cost?
    • What resources will be required, in development, testing, internationalization, cross-product coordination, documentation, etc., etc.? Because resources are limited, what other features or enhancements would not be completed because this one is being done?
    • How would this be incorporated in the marketing of Office? Who are the intended audience, and how would they hear about the new ability?

    Was this answer helpful?

    0 comments No comments