There are (at least) a couple of ways to install a macro. I will talk you through what is probably the most straightforward method later in this post, but first let us look at what a macro looks like inside Word’s Visual Basic for Applications (VBA) editor. (I'm going to skip the 'for Applications' bit for simplicity.) What do macros look like?This is what the SmallCaps macro that we recorded in this post looks like in the Visual Basic editor: All macros have the same basic structure:
You can see that it has the same structure as the SmallCaps macro, but there are fewer instructions in the body of the macro. How to install a macroFirst, go to View Macros in the Macros section of the View tab. (See the first part of this post if you’re not sure). When you click on View Macros you get a pop-up box which looks like this: Type the name of the macro that you want to install into the top box (underneath Macro name:). I am calling my new macro TestMacro. Remember: macros are a throw-back to the old days of file naming systems so you can’t use spaces! When you have typed the name in, click on ‘Create’. This will bring up the Visual Basic editor (which is what we were looking at earlier). Clicking on 'Create' for my new macro, TestMacro, gives me: You need to copy the body of the macro you are installing from the source document (this will probably be a web page or a Word doc) and paste it below the green quote marks and above End Sub (the cursor should automatically be in the correct place). For my PatientsWith macro, the part that I need to copy and paste is: Selection.Cut My new macro – called TestMacro – will then look like this: It’s important that you are careful to paste your text exactly where it needs to go. You will find that the Visual Basic editor automatically creates lines between each macro in your list of macros. Be careful not to delete these lines. *** Only copy and paste macros from sources that you trust. Macros are powerful and there are macros which are able, for example, to delete all your files if you run them. *** You then need to save your macro in the Visual Basic editor, using the Save icon at the top left-hand side. Then close the editor (via the File menu or the cross on the top right-hand side). When you open your list of macros, it should now contain your new macro: Type a description of what your macro does in the 'Description:' box at the bottom. Alternatively, if you have copied a complete macro (from a trusted source), you can click on 'Edit' in this pop-up box: Go back to: Macro baby steps part i
Archives November 2023 Categories All
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
Details
AuthorAndrea at Yours Truleigh Editing Archives
September 2024
Categories
All
|