For hiking I don't bother with a flash. I just pump the ISO as hard as I can and use either the stabilized 17-85mm or when I really need the lens speed, the 50mm f/2. If I could afford it (and justify it) I'd get the 70-200 f/2.8 L-series.
However, for events (weddings, parties, etc.) having an external flash is crucial.
With my 40D I use a Speedlite 580EX II and it's wonderful. It's top of the line, but IMHO it's not worth having an underpowered flash. I can bounce off high ceilings or do direct flashes from a long distance. With the 40D I can either use P mode and everything will coordinate, or use Av or Tv and the camera will meter as if there was no flash and then fire the flash for fill, or use full M mode and set to, say, 1/125 and f/4 to f/8 and it will meter in real time when the flash fires. I can control all the features of the flash from either its own controls or from the camera's menus. I have an old 420EX and can use it as a remote slave to the 580 to really even out the shadows in portraits or stills. It also helps autofocus in dim light by sending out a grid pattern of red lines, as opposed to the built-in flash which has to strobe. And of course an external flash is far enough away from the lens to really minimize any red-eye effects (and bouncing you won't get any). Also, it has a built-in extendable bounce (catchlight) card, and diffuser. And while it has a quick recycle time, you can also buy an external power pack for it if you're going to be taking a lot of shots quickly.
Okay, it's a pretty penny, but if you're serious about your 40D, get the serious flash that will work for you in all conditions and scenarios.
edit: the other nice thing about a high-end flash is that based on exposure it can really dial its power back, so if doing, say, a closeup of some plant, it's possible to not completely wash it out. And if you're trying to get one of those really nice photos of a dark, colorful sunset with a deer or moose in the foreground lit by fill flash, it can fire its guts out with a 58 guide number.