SOLVED How to activate the recent Saved Document

Dear Developers,

I have a python script which saves the unsaved (untiteled) active document to a *_imported.c4d file which works fine, but Cinema still has the original "Untiteled" Filename active how can I activate the successfully saved file in Cinema 4D and discard the "untiteled"

thanks in advance.

here is my save method:

    def savedoc(self, doc):
        c4d.StatusSetText ('Saving Document.')

        path = self.folderpath
        if doc.GetDocumentPath():
            path = doc.GetDocumentPath()

        name = doc.GetDocumentName()    
        # an unsaved doc has no extension we have to check
        if name[-4:] == ".c4d":            
            newname = name # the user has his own document we dont change the name
        else:
            newname = name + "_imported.c4d" # the user has no document we give a little context
            
            # c4d does not update to _imported.c4d doc.
            #doc.SetName(newname)            
            #c4d.documents.SetActiveDocument(doc) 
            
        filename = os.path.join(path, newname)
        
        print ("Saving file to: ",  filename)        
        c4d.documents.SaveDocument( doc, filename,                                     c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST | c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, format=c4d.FORMAT_C4DEXPORT)

@mogh Did you try doc.SetDocumentName(newname)?

@mogh Did you try doc.SetDocumentName(newname)?

No stupid me,
overlocked this ... thanks for the hint Frank.