Secrets of the Office Masters: Elements of Programming Style for the Nonprogrammer

Even if you're new to programming and have only just begun writing your first VBA programs, you should always keep several tips in mind:

  • Use lots of comments. Yes, you can remember precisely what each line of code in your program does, and what each variable's duty in life might be. But when you look at your program a year from now, it will all be gibberish unless you add a lot of comments now, while it's still fresh in your mind.

  • Don't be afraid to experiment. You aren't going to break anything. The real beauty of VBA is that you can try something, see how (or whether) it works, and then try something else. Amazing things have been discovered by trial and error.

  • Remember that nothing is perfect, and VBA certainly follows that rule. Although VBA itself is reasonably stable and predictable, the underlying object models in all the Office applications have lots and lots (and lots and lots) of rough edges. Go slowly, step through all your programs, and be observant.

  • Test. Then test some more. Then give your program to 10 friends, and have them all test it even more. Everyone has a slightly different configuration, and odd settings can throw off even the most well-conceived program.

  • Keep your sense of humor. Programming is fun. But it's also hard work. The machine isn't out to get you—even though there will certainly be days when you think it is.

  • Ask questions. Nobody knows it all. And even if they did, by the time they figured out the last nuance of the last feature, they would've forgotten what they knew in the first place.

  • No matter what happens, there's always another revision. VBA is a dynamic language and every new version brings some exciting new capabilities. Stay on top of the wave, and you'll be able to solve problems that would curl the hair of mere mortals.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.173.242