Absorption lines at high-redshift in front of quasars are quite rare in the millimeter (mm) domain. Only five associated and five intervening systems have been reported in the literature. Nevertheless, these discoveries provide very useful information that is complementary to emission lines, allowing, for instance, to distinguish between inflows and outflows. These lines are also good candidates for studying the variations of the fundamental constants of physics. Here we report the findings of our search for CO and other molecules in emission and absorption in front of a sample of 30 targets, comprising 16 associated and 14 intervening H I 21 cm absorbers. The observations were made with the IRAM-30 m telescope simultaneously at 3 mm and 2 mm, exploring several lines of the CO ladder and HCO+, depending on the redshift. We detected eight targets in emission, of which five are new. The derived molecular gas masses range from 109 to 7 × 1011 M⊙ and the highest redshift detection (z = 3.387) corresponds to a relatively average-metallicity damped Lyman-α absorber for this redshift. We also report four new detections in absorption. Two of the associated CO absorption line detections at high-redshift (z = 1.211 and 1.275) result from high-spatial-resolution follow-up observations with NOEMA. The disparity between the mm molecular and H I 21 cm absorption lines for these and another intervening system detected in HNC at z = 1.275 is attributable to radio and mm sight lines tracing different media. We compare the atomic and molecular column densities of 14 known high-redshift (z > 0.1) molecular absorption line systems. The associated H I absorption lines are broad and exhibit multiple components, and the molecular absorption generally corresponds to the broader and weaker 21 cm absorption component. This indicates two distinct phases: one near galaxy centers with a larger CO-to-H I abundance ratio, and another with lower molecular abundance in the outer regions of the galaxy. In comparison, intervening absorption profiles correspond primarily to H I-dominated gas structure in galaxy outskirts, except for gas at low impact parameters in gravitationally lensed systems. The comparison of interferometric and single-dish observations presented here shows that the detection of absorption requires sufficient spatial resolution to overcome the dilution by emission and will be an important criterion for mm follow-up of 21 cm absorbers from ongoing large-scale surveys.