The actor shot to fame as Captain James T Kirk, commander of the starship USS Enterprise, in the sci-fi series which originally ran from 1966 to 1969.
He has reprised the role numerous times over the years, as well as starring in hundreds of films and TV shows including TJ Hooker, 3rd Rock From The Sun, Boston Legal and Miss Congeniality.
The 90-year-old’s latest role is in Senior Moment, as a retired Nasa test pilot and self-proclaimed ladies’ man who loses his driving licence and meets a woman, played by Jean Smart, who changes his life.
Read more: Shatner rules out playing Kirk ever again
Discussing why he still works so hard, Shatner told the PA news agency: “I’ve got a very full, creative life, I’m more creative now than I’ve ever been. And so that aspect of my life has not slowed down.
“Something very meaningful was said to me a while ago by an agent, who said ‘Every time I talk about you, they ask me about your age because of insurance’. They talk about ‘Can we insure that guy?’
“So that’s a problem for an ageing actor, and what I seem to have done, basically inadvertently, is use my wits and my intelligence to do other things.
“As a young actor, you’re always balancing on the precipice of failure and you’re about to fall all the time.
“And you stumble back and something comes along and it’s successful, you’re OK for a while and then you agonise over everything.”
Watch: William Shatner to preserve his life through AI
Shatner, who will release an album called Love, Death And Horses later in the summer, said he wishes he knew when he was younger that fame and success do not prevent loneliness.
He said: “The album is autobiographical and one of the songs is about loneliness, how much loneliness was a part of my life.
Read more: Shatner hits back at fans over autographs
“It is a part of everybody’s life, no matter how much attention you get, and how happily married you are, and how many children you have.
“As the song says, we’re all essentially alone and the big mystery is will there be anybody there at the end?
“So loneliness is a huge aspect to what I felt all those years ago, but I’m still alive. I’ve still survived loneliness.
“Had I known all those things, I might have assuaged that, but, if I knew then what I know now, I wouldn’t know now what I know.”
Shatner said he attributes the energy he still has to “DNA, no question about it” and added: “I have lived a good life. I don’t do drugs, I don’t drink and smoke, and I try to exercise as much as possible, with good food.
“I’ve been healthy, I’ve had the good luck to never have been really sick. I’ve had my share of colds but I’ve never had any debilitating disease.”
However, he revealed he is currently suffering from a serious injury, saying: “My shoulder is shattered right now. I cracked the bone falling off a horse a couple of weeks ago.
“So my left arm is bad but I keep exercising it. It’s getting better and better.
“I had to get on an aeroplane the other week and at the airport you go in that (scanner) and they go ‘Raise your arms’, but I couldn’t so they had to poke and prod and take my shoes off and it took 15 minutes, it was so demeaning.
“But I’ve had the good luck of not having anything really debilitating. So nothing has sapped my energy.”
Senior Moment is available on digital platforms from 28 June.
Watch: William Shatner talks to Yahoo about Senior Moment