Most of the time. Because air leakage is the culprit, the only way to eliminate moisture problems is to air-seal the building envelope. By eliminating air movement through walls, floors, and ceilings, moisture-laden air cannot pass through and affect the indoor environment. This allows you to control humidity levels to within the 45-50% range — a level at which molds, mildew, dust mites, and many allergens cannot be sustained. However, spray foam cannot be used to stop leaks. You need to call a roofer for that problem!
It also won’t eliminate problems in situations that introduce unusual moisture into a home, for example a hot tub or pool. In those cases, humidity must be controlled with a mechanical system.