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-21T20:02:38+00:00

    Jay -

    You are absolutely correct that the business case must be considered, and I believe there is a good business case that can be made for MS to consider doing something to improve use and accessibility to the macro capabilities of the Office Applications. 

    I want to be very clear about my goal in this discussion:  While I have my own personal "wish" item (that it should be easier for an ordinary user to automate a macro to execute repeatedly through [a paragraph, a section, a page, or the entirety of] a document), my goal in this discussion is consideration, and I hope gain support, for MS to add to the macro facility of its applications a set of additional tools designed to help users "automatically" add certain more complex functionality to existing macros so users can accomplish more with macros without having to learn programming principles. 

    What are those items of more complex functionality?  Well, one certainly would be to cause an existing macro to repeat itself (as I already described); another might be to cause an existing macro to execute on all or a selection of documents in a folder; and I'm sure there are others that could be added just from the experiences frequently reported by users here and on other forums. 

    So, what is the business case? 

    Well, the first thing to note is that I don't agree that a product change must be justified by showing that it will generate additional revenues.  The MS Office applications are near-ubiquitous, so there aren't many "new users" to go after and the income stream now is largely dependent on upgrade revenues.  So the more correct question ought to be "will it help Microsoft convince users to upgrade sooner than they otherwise would?" 

    These are mature applications and, over the past several versions, there really haven't been major additions to their functional capabilities, and I don't think anyone really expects there will be significant functional capabilities added to any of these products.  So instead of adding new functional capabilities to convince users to upgrade, the major version 'improvements' have been to the interface and to add ways to make the products' existing capabilities easier or more accessible for users (Quick Styles, for example).  So providing a few tools to make the products' macro capabilities easier and more accessible would fit in very well with Microsoft's existing "product improvement philosophy" -- and it would be in a functional area they haven't yet tried to enhance/improve. 

    Of course, no one outside of Microsoft can possibly know the amount or type of resources that might be required to incorporate a set of "macro-building" tools into these applications.  But I also don't think Microsoft will even begin to think about that issue until after the right people within MS begin to hear that it's a concept they should consider. 

         "How would this be incorporated in the marketing of Office? Who are the intended audience,

          and how would they hear about the new ability?"

    I suspect the principal intended audience ought to be the decision-makers for customers deciding whether and when to upgrade from the previous version of the product(s).  Certainly marketing experts would know better than I what specific message to convey and how, but one message I think would be important to those decision makers would be something like: 

          "Using macros can produce significant productivity improvements for users and your business. 

           But we know that not every user has the time or ability to become completely fluent in the

           macro language and can lose time trying to get a macro "just right"; so in the new version of

           [Word, Excel, etc.] we have included several macro-building tools intended to help users quickly

           make their macros more powerful and effective.  That time-saving is a productivity improvement

           that goes right to your bottom line."

    Another audience, of course, would be users themselves (to get them to lobby their decision makers to upgrade): 

           "Frustrated that you can't easily get your macro to repeat execution throughout your document

            or that you don't know how to automate applying your macro to several documents in the

            same folder?  The macro enhancement tools in the new version of [Word, Excel, etc.] are

            designed to add these capabilities and others to your existing macros without you having to

            research and manually code the required macro commands.  It's another way that the new

            [Word, Excel, etc.] can make your job easier and make you more productive." 

    Anyway, I do think there's a good business case for this as an area for Microsoft to improve its products and it's totally consistent with the types of "product improvements" it has to continue making to be able to convince users and their employes to upgrade. 

    Thanks for bringing up the commercial issue.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-02-21T20:27:54+00:00

    Thanks Peter.  All great thoughts. 

    However, I was NOT intending to suggest any of the following: 

    • modifying the macro recorder at all (and certainly not the process by which it operates -- I apologize if this wasn't clear);
    • modifying anything about the find/replace process;
    • making any change to any part of the application itself or the macro language that would affect the continued efficacy of existing macros or the continued expectations of existing users, insofar as their reliance on existing capabilities of the application or its macro capability is concerned;
    • requiring any change to the existing "object model" (at least as I understand what that is)

    I believe what I was trying to express could be accommodated by just providing an additional set of tools (maybe just Wizards?) that would "add to, without changing" (which I think is what you mean by an "extensibility mechanism"). 

    The concept would be that the new "tools" would add more complex functionality to an existing macro (regardless of whether that existing macro had been written from scratch, copied, or recorded) by doing something like:  (1) copy the selected macro's existing code, (2) create and name a new macro into which it inserts the copied macro code, and (3) insert pre-determined VBA commands before, after, or both before and after (whichever would be required to achieve the functionality intended for the tool) the unchanged text of the copied macro code. 

    Or, I suppose another (perhaps better, but doubtless more difficult) approach could be for Microsoft to develop and include a Macro-Building Assistant -- maybe something like the formula-building assistant in Excel.  Or even just "increasing the intelligence" of the debug tool in VBA that, on finding an error, will provide suggestions that attempt to understand what the user may be trying to do and provide more specific instructional materials at that point. 

    As I said in my earlier response to Jay, I believe that improving accessibility and ease of use for the macro capability is completely consistent with the types of product enhancements Microsoft has been pursuing. How they do it is really not nearly as important as that they try to do it.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-02-22T00:28:13+00:00

    Thanks for the response, but it sort of proves what I said before -- that, for ordinary occasional users, it IS more complicated than it seems like it ought to be to have a macro do what seems to be a pretty simple thing. 

    I see you are getting a lot of push back on this.  I just want you to know that another user agrees with you.  

    When Word was introduced at the agency where I worked in '96 or '97, I was a pretty good macro writer in the two wordprocessors I had used and knew two or three scripting languages at least well enough to complete projects.  When I asked about the macros in Word, our computing division said that Word's macro language was a professional language and that they would write macros for us  (big joke).  As proof of this idea, I suppose, there was no macro recorder in the version of Word installed on our computers.   Nothing I have learned since really disputes that. 

    But the people responding to you are experts, generous and helpful experts, who easily dash off code in minutes and will never agree with you.

    Was this answer helpful?

    0 comments No comments