My understanding of how Window Activation works is pretty simple. It restores the most recently use window of that type. That default behavior makes coding what you want very simple. In fact, I do something almost identical to what you are after with two simple code blocks.
SetTitleMatchMode, 2 ; approximate match
IfWinExist, - Microsoft Word
WinActivate, - Micrsoft Word
IfWinNotExist, - Microsoft Word
I created a bit of an interesting synergy to work with multiple monitors. Note that on Windows 7, holding shift + windows key and using the arrows to navigate left and right will move the active window between monitors at light speed. So I tried something a bit clever and mapped word to shift + window + w. It restores word if already open or runs a new instance if not. The beauty of the approach is that I never let go of shift + windows key. By doing so I can both active/start word and move it to exactly the position I want using left right arrow keys (up will maximize by the way and down will minimize). Map +#r to restore the active window and you completely control all windows that you normally use effortlessly without the mouse. All you must remember is the first letter of the app you are trying to activate.
In answer to your query about making the script more generic:
1) Consider using
; Allows you to search for an approximate window title match
; For example, you could do the following to activate any existing window with
; "- Microsoft Word" as part of the title
WinWait, - Microsoft Word,
IfWinNotActive, - Microsoft Word, , WinActivate, - Microsoft Word,
WinWaitActive, - Microsoft Word,
; some other code here once you have the window active
Or another possibility:
;Active the window by finding its ahk_class
WinWait, ahk_class OpusApp,
IfWinNotActive, ahk_class OpusApp, , WinActivate, ahk_class OpusApp,
WinWaitActive, ahk_class OpusApp,
Note: The code above was just an adaptation of the autoscriptwriter's generic output. It is somewhat redundant but effective. To find something like a window's ahk_class consider using AutoIt3 window spy.
If you need to discover the title of a window you can get active title as shown in the ahk example help file
MsgBox, The active window is "%Title%".
Another trick you can use is to set the active title using WinSetTitle
Edit: Given that you have multiple instances of excel/word/powerpoint floating around, also consider solving that problem with officetabs free edition. It will allow you to keep all open excel files in a single instance for example instead of strewn about the taskbar.