Try this
(defun rh:sammlung_n (o_lst grp / tmp n_lst)
(setq n_lst nil)
(cond ( (and o_lst (= (rem (length o_lst) grp) 0))
(while o_lst
(repeat grp (setq tmp (cons (car o_lst) tmp) o_lst (cdr o_lst)))
(setq n_lst (cons (reverse tmp) n_lst) tmp nil)
);end_while
)
);end_cond
(if n_lst (reverse n_lst))
);end_defun
(vl-load-com)
;; Move Text to Line along text rotation
(defun c:MT2L ( / *error* c_doc c_spc l_obj ent e_lst ss t_obj i_pt t_rot x_obj x_pts s_d x_pt)
(defun *error* ( msg )
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error occurred : " msg)))
(princ)
);end_defun *error*
(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
);end_setq
(while (not l_obj)
(setq ent (car (entsel "\nSelect Line : "))
e_lst (entget ent)
);end_setq
(if (vl-position (cdr (assoc 0 e_lst)) (list "ARC" "LINE" "LWPOLYLINE" "RAY" "SPLINE" "XLINE")) (setq l_obj (vlax-ename->vla-object ent)))
);end_while
(setq ss (ssget '((0 . "*TEXT"))))
(repeat (setq cnt (sslength ss))
(setq t_obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt))))
i_pt (vlax-get t_obj 'insertionpoint)
t_rot (vlax-get t_obj 'rotation)
x_obj (vlax-invoke c_spc 'addxline i_pt (polar i_pt t_rot 1.0))
x_pts (rh:sammlung_n (vlax-invoke x_obj 'intersectwith l_obj acextendnone) 3)
s_d 1.0e200
);end_setq
(cond ( (> (length x_pts) 1) (foreach pt x_pts (if (< (distance pt i_pt) s_d) (setq x_pt pt s_d (distance pt i_pt)))))
(t (setq x_pt (car x_pts)))
);end_cond
(vlax-invoke t_obj 'move i_pt x_pt)
(vla-delete x_obj)
);end_repeat
(princ)
);end_defun
It will move the text to the nearest intersection (if more than 1) using the text angle. See attached dwg
MT2L.dwg