Try with this
(defun c:my_txtexp ( / ss n ent dxf_ent lay sel lastent next lastent e dxf_e)
(setq ss (ssget ":L" '((0 . "*TEXT"))))
(cond
(ss
(if (not c:txtexp) (load "txtexp"))
(repeat (setq n (sslength ss))
(ssadd)
(setq
ent (ssname ss (setq n (1- n)))
dxf_ent (entget ent)
lay (cdr (assoc 8 dxf_ent))
sel (ssadd ent)
lastent (entlast)
)
(sssetfirst nil sel)
(c:txtexp)
(if (and lastent (entget lastent))
(progn
(setq
sel nil
sel (ssadd)
)
(while
(setq next (entnext lastent))
(ssadd next sel)
(setq lastent next)
sel
)
)
)
(if sel
(repeat (setq i (sslength sel))
(setq
e (ssname sel (setq i (1- i)))
dxf_e (entget e)
dxf_e (subst (cons 8 lay) (assoc 8 dxf_e) dxf_e)
dxf_e (subst (cons 62 256) (assoc 62 dxf_e) dxf_e)
)
(entmod dxf_e)
)
)
)
)
)
(prin1)
)