Microsoft actually built that already, then they decided to kill it. It was called VSTA (not to be confused with VSTO). It shipped with one of the apps of Office 2007.
I am also aware of a commercial product that offers a .net IDE to be embeded into your software, though I never tried it: https://www.alternetsoft.com/products/scripter