Dr. McCoy might have been cantankerous, but he didn't stick patients with needles. Instead, he used a device called a hypospray, which sprayed medicine into a patient's blood stream directly through the skin.
Hyposprays exist today, though they're called jet injectors. They're expensive, so they're still not as commonly used as needles. But they're less painful.