Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I make a macro that does something whenever a specific text is entered on Word.

Can you give me a simple example of a macro that, for instance, is run every time some text is entered between braces (like this: [Some Text]) changing the text to bold (so after the last "]" is typed it turns into [Some Text])?

PS: I know stuff like this can probably be done with AutoFormat or something, but I was just looking for a simple example that helps me learn macros.

PPS: Unfortunately, I'm running Office 97! But even an answer that is only compatible with newer version is appreciated.

share|improve this question

migrated from stackoverflow.com Feb 11 '13 at 1:32

This question came from our site for professional and enthusiast programmers.

    
The only part of your problem that is more difficult than recording a find and replace macro is that you want to make it happen automatically. Why do you need that feature? –  Seth Battin Feb 9 '13 at 0:16
    
I'm just wondering what can be done with macros. Isn't there a KeyTyped event or something? For instance with this I could code a macro that autoreplaces [myimage] with an image object downloaded from myserver.com/myimage.png. Well many things can be done, it's just strange to me that macros can't be started that way... –  Test test Feb 9 '13 at 0:23
    
(Or for instance I could try to autoreplace [8+8] with an Equation object containing 8+8...) –  Test test Feb 9 '13 at 0:27
    
What I meant was, you want to parse your text when you're done writing it. Why not hit a button to parse that text instead of having something that runs after every keystroke? Or even better, something that parses your currently selected text? –  Seth Battin Feb 9 '13 at 2:26
    
There is no action that is triggered when you type text in MS Word document, so what you asked is not possible to do. Even if there is I have to agree with @SethBattin That will degrade performance. I think you can practise macros using better examples than this. –  Buddha Feb 10 '13 at 15:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.