We demonstrate enhanced absorption in solar cells and enhanced light emission in OLEDs by light interaction with a periodically structured microlens array. We simulate n-i-p perovskite solar cells with a microlens at the air-glass interface, with rigorous scattering matrix simulations. The microlens focuses light in nanoscale regions within the absorber layer enhancing the solar cell. Optimal period of ~700 nm and microlens height of ~800-1000 nm, provides absorption (photocurrent) enhancement of 6% (6.3%). An external polymer microlens array on the air-glass side of the OLED generates experimental and theoretical enhancements >100%, by outcoupling trapped modes in the glass substrate.