Dan,
Made minor revision. Please see below. Btw, you're welcome.
(defun C:PREFIXSHEET (/ loName ss Tab_prefix loName2)
(vl-load-com)
(vlax-for objLo (vla-get-layouts
(vla-get-activedocument (vlax-get-acad-object))
)
(if (and (not (= (setq loName (vla-get-name objLo)) "Model"))
(setq ss (ssget "x"
(list (cons 0 "INSERT")
(cons 2 "TITLE,TITLE3")
(cons 410 loName)
)
;Replace "TITLE,TITLE3" with your title block name(s)
)
)
(setq Tab_prefix (_Get_AttValByTag (vlax-ename->vla-object (ssname ss 0))
"SHEETNUMB"
;Replace "SHEETNUMB" with your tag string
)
)
(not
(vl-position (setq loName2 (strcat Tab_prefix " " loName))
(layoutlist)
)
)
)
(vla-put-name objLo loName2)
(prompt
(strcat "\nSomething isn't right with layout " loName ".")
)
)
)
(prompt "\nDone.")
(princ)
)
(defun _Get_AttTagVal (oBlk)
(if (= (vla-get-hasattributes oBlk) :vlax-true)
(mapcar (function (lambda (oAtt)
(list oAtt
(vla-get-tagstring oAtt)
(vla-get-textstring oAtt)
)
)
)
(vlax-safearray->list (vlax-variant-value
(vla-getattributes oBlk)
)
)
)
)
)
(defun _Get_AttValByTag (oBlk tag / lstAtt lstVal)
(if (and (setq lstATV (_Get_AttTagVal oBlk))
(setq @ (vl-position (strcase tag)
(mapcar 'strcase (mapcar 'cadr lstATV))
)
)
)
(caddr (nth @ lstATV))
)
)
(princ)