The best way to handle this situation is to use launch conditions
You can open the launch condition editor by right-clicking on your Setup Project and selecting
View->Launch Conditions

Detect an existing application
One way to detect an existing application you can set up a Registry Search and Launch Condition (Right click Search Target Machine -> Add Registry Search)
The properties for the Registry search for office 10 might be
Name: Search for Office 10
Property: OFFICE10REGISTRY
RegKey: SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot
Root: vsdrrHKLM
Value: Path
Then you can add launch condition of with these properties
Name: Office Installed Condition
Condition: OFFICE10REGISTRY
Message: Office 10 not detected
If you want to search for any Office version you can create several registry searches and then use the condition of OFFICE10REGISTRY OR OFFICE11REGISTRY OR OFFICE12REGISTRY
.
Detect an assembly installed in the GAC
This time you add a File search to search for the installed file in the gac.
Name:Search for Assembly In GAC
Depth: 5
FileName: Microsoft.JScript.dll
Folder: [WindowsFolder]\assembly\GAC\Microsoft.JScript
MaxVersion: 8
MinVersion: 7
Property: JSCRIPTEXISTS
Note that file name is the dll and the folder follow the pattern of the namespace. Also note you can specify just the min versions if you want.
Then adding a Launch Condition
Name: Assembly Gac Condtion
Condition: JSCRIPTEXISTS
Message: Missing JScript
When you're done the end result might look like this
