@leonucadomi Actually - I think this version will work better i it will prevent it from stripping other formatting for the reason Lee Mac noted here:
; Original by RonJonP, edited by P. Kenewell
(defun c:ltx (/ o s)
(setvar "cmdecho" 0)
(command "._undo" "_be")
(if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
(foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
(setq o (vlax-ename->vla-object e))
(cond
((= "TEXT" (cdr (assoc 0 (entget e))))
(vla-put-textstring o
(strcat "%%U%%O"
(vl-string-subst "" "%%U"
(vl-string-subst "" "%%O" (vla-get-textstring o))
)
)
)
)
((= "MTEXT" (cdr (assoc 0 (entget e))))
(vla-put-textstring o
(strcat "\\L\\O"
(vl-string-subst "" "\\L"
(vl-string-subst "" "\\O" (vla-get-textstring o))
)
)
)
)
((= "DIMENSION" (cdr (assoc 0 (entget e))))
(if (= (vla-get-textoverride o) "")
(vla-put-textoverride o "\\L\\O<>")
(vla-put-textoverride o
(strcat "\\L\\O"
(vl-string-subst "" "\\L"
(vl-string-subst "" "\\O" (vla-get-textoverride o))
)
)
)
)
)
)
)
)
(command "._undo" "_end")
(setvar "cmdecho" 1)
(princ)
)