You'll probably need to tweak at least half the macros you have or use, to fix them or to make them do something extra. In addition, if others are going to use and perhaps troubleshoot your macros, it's a good idea to add comments describing what some of the lines do. Note You'll be relentlessly prompted for a password if you try to edit the existing macros. You just can't. Which is probably just as well. You can add them, unedited, to documents using the procedures covered in Adding a Macro to a Document on page 976. Adding CommentsTo add descriptions about what lines do in the macro, just press Enter to add a new line, and begin the line with a single quote or the letters REM in all uppercase. 'This line starts an animated GIF showing two 'right-handed men fencing. Documents.Open( "file:///home/magentaf/gifs/inigo.gif") Comments are shown in light gray text. Troubleshooting TipsWhen an error occurs when you're running a macro, an error message will appear and Basic will point to the line containing the error. Pinpointing problemsIf you're having problems, always use the Single Step feature to run the macro one step at a time (see Running a Macro One Step at a Time on page 973). If the error occurs late in the macro, add a breakpoint. Comment out lines that are creating problems. If it's optional, add a single quote mark in front of it to "comment it out". The text will turn gray and the macro will run without that line. You can use this technique to pin down the source of errors. Macros that create new filesFor macros that create new files, you might need to edit some of the macros. The following lines are generated when you create a new Writer file, for example: [View full width]
If you already had an untitled document open, though, the line will be recorded as Untitled1 :1 instead and you'll get an error when you run the file. The program likes all the untitled files it opens to be titled Untitled1 . Change this line if you encounter errors. You can't edit the file name so that it's named "Annual Report" or whatever you're going to save the document as; the program will complain and give you an error. Note Web has a feature that lets you create hyperlinks that open new files. You might want to use it instead, if appropriate for your project. See Linking to a New Empty File on page 476. |