(defun c:area2xls (/ SelSet Test AreaFile File#1 Counter Obj Area Layer ) (if (setq SelSet (ssget '((0 . "LWPOLYLINE") (70 . 1))) ) (setq Test T ) (setq Test nil ) ) (if (setq AreaFile (getfiled "Select a location to save the area information..." (substr (getvar "DWGNAME" ) 1 (- (strlen (getvar "DWGNAME" )) 4 ) ) "csv" 1 ) ) (setq Test T ) (setq Test nil ) ) (if Test (progn (setq File#1 (open AreaFile "w" ) ) (write-line (strcat "Area List for " (getvar "DWGPREFIX" ) (getvar "DWGNAME" )) File#1 ) (princ "\n" File#1 ) (vl-load-com) (setq Counter 0 ) (write-line (strcat "Layer\tArea") File#1 ) ; ! Tabs ! (while (ssname SelSet Counter ) (setq Obj (vlax-ename->vla-Object (ssname SelSet Counter )) ) (setq Area (vlax-get Obj "Area" ) ) (setq Layer (vlax-get Obj "Layer" ) ) (vlax-release-Object Obj ) (write-line (strcat Layer "\t" (rtos Area ) ) File#1 ) ; ! Tabs ! (setq Counter (1+ Counter ) ) ) (close File#1 ) (princ (strcat "\nCommand: " (itoa Counter ) " areas has been written to " AreaFile ) ) (princ "\nDouble-click on that file to open it in Microsoft Excel." ) (startapp "C:\\Program\\Microsoft Office\\Office10\\EXCEL.EXE" AreaFile ) ;; Path !! ) (princ "No file created" ) ) (princ) ) (prompt "\nType Area2xls to generate a list of selected area object into Excel." ) (princ)