Have you tried using
Autodesk.AutoCAD.Internal.Utils.GetTextExtents
This gives you a point2d of the extents of the text which you can then use to figure out where to draw your frame (i.e. by adding this point onto the location of your text).
Kind of like this
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim mTxt As MText = trans.GetObject(oid, OpenMode.ForRead)
Dim pext As Point2d = Autodesk.AutoCAD.Internal.Utils.GetTextExtents(db.TextStyleTableId, mTxt.Contents, 200)
Dim pline As New Polyline
pline.AddVertexAt(0, New Point2d(mTxt.Location.X, mTxt.Location.Y), 0, 0, 0)
pline.AddVertexAt(1, New Point2d(mTxt.Location.X + pext.X, mTxt.Location.Y), 0, 0, 0)
pline.AddVertexAt(2, New Point2d(mTxt.Location.X + pext.X, mTxt.Location.Y - pext.Y), 0, 0, 0)
pline.AddVertexAt(3, New Point2d(mTxt.Location.X, mTxt.Location.Y - pext.Y), 0, 0, 0)
pline.Closed = True
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = trans.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
btr.AppendEntity(pline)
trans.AddNewlyCreatedDBObject(pline, True)
trans.Commit()
End Using
It seems to work ok whether in world or ucs if the angle of the text is 0. If the text itself is rotated then you'll need to transform your frame to rotate it to the same angle as the text.
It won't work for text that's rotated in 3d though.
It will also only work in 2010 as I don't think the ...Internal.Utils.GetTextExtents is available prior to that.
HTH