I doubt it, if the doctor just turned up in the 41st millenium then they would kill him for being a witch. One of his most used tactics is to gain access to wherever with his psychic paper- eventually he would try that against a librarian who would spot the psychic influence, resist it, then kill the Doctor.
I don't think the Op actually meant had the Dr. gone to 40K-verse but on his travels had he travelled somewhere between the years 30,000-40,000 A.D.
I'm not sure if the Dr. has actually done it on the show but considering how long lived he is and how many places he's been without a companon I consider it likely he has visited that time period at some point.
A forum community dedicated to Warhammer, Warhammer 40K enthusiasts. Come join the discussion about Warhammer and Wargaming collections, miniatures, tactics, terrain, reviews, accessories, history, displays, models, styles, scales, reviews, accessories, classifieds, and more!