In the Revit API there is the following function to set an document active in Revit.
application.OpenAndActivateDocument(file)
Problem is, it needs a filename but it seems unlogical, since the document is already openend. The normal way to get a filename is by using Document.Pathname.
But since people are using Revit Server, Bim 360 docs ect. the Document.Pathname is empty, so you can rely on it. That's why it would be hugely appriciated when the API would be expanded with a function like:
application.SetActiveDocument(Document)
Where you could pass a document instead of a filename.