Slice-specific z-shimming reduces signal losses caused by through-slice dephasing in spinal cord fMRI acquisitions. Typically, the optimum values are determined from a reference acquisition covering a range of z-shim values by a user who identifies the setting with the least signal loss. However, this procedure requires some experience, is time-consuming, and user-dependent. Here, an automated calculation of the optimum values has been developed, implemented on the MR system, and evaluated in phantoms and in vivo. Without compromising the image quality, the approach is faster and user-independent and, thus, may help to facilitate the application of z-shimming in spinal cord fMRI.