It could be something like this:
(defun C:HT (/ ctextc sset index area obj)
(defun ctextc (stringa / html result)
(if (= (type stringa) 'STR)
(progn
(setq html (vlax-create-object "htmlfile")
result (vlax-invoke
(vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData)
'setData
"Text"
stringa
)
)
(vlax-release-object html)
result
)
nil
)
)
(if (>= (atof (substr (getvar "acadver") 1 4)) 16.2)
(progn
(prompt "\nSelect hatches: ")
(if (setq sset (ssget '((0 . "HATCH"))))
(progn
(setq area 0)
(repeat (setq index (sslength sset))
(setq obj (vlax-ename->vla-object (ssname sset (setq index (1- index))))
area (+ area (vla-get-area obj))
)
)
)
)
)
)
(princ (strcat
"\nTotal area = "
(if (or (= (getvar "lunits") 3) (= (getvar "lunits") 4))
(strcat (rtos area 2) " sq. in. (" (rtos (/ area 144) 2) " sq. ft.)")
(rtos area)
)
)
)
(ctextc (vl-string-subst "," "." (rtos area)))
;;; (ctextc (rtos area))
(princ)
)
The result of the area obtained is available by simply pasting the content (Ctrl+V) on a command line, Word, Excel, etc...
The heart of the program is the ctextc function that captures the result and makes it available immediately.
Just one thing, in my country we use commas for decimals, so if that's not your problem just put the three commas on the previous line, like this:
;;;(ctextc (vl-string-subst "," "." (rtos area)))
(ctextc (rtos area))