Here you go, I've modified it a bit to omit making an xls file and added some notes that should help you.
First thing you need to do is create a drawing in "C:\Temp" and save it as "dext.dwg". Include ANY blocks that you want to perform the data extraction on (from any of your dwgs). Once you've done this, make a dxe file using the regular, dialogue-driven DATAEXTRACTION command. Set all the options that you want (select all the attributed blocks you want to get info from). Save this dxe file as "dext.dxe". So basically, you've got a dext.dwg and a dext.dxe in the c:temp folder. In the temp directory, make a copy of dext.dxe and call it dext-orig.dxe
You only have to do this once to set up the data extraction template. I don't know what version of acad you're running, so check the command line version of SAVEAS to assure that it saves as "2010".
As for DOSLib, just make sure those files are in your support path. This loads it when you run DEXT.
And, I forgot to mention, the error handling doesn't work, so don't hit escape or anything while it runs (it takes a few seconds).
Let me know if it works for you!
Code:
(vl-load-com) ;LOADS VISUAL LISP COMPONENTS
(dos_demandload) ;LOADS THE DOSLIB FILES
(defun c:dext ( / *error* vars old dn dp dwg) ; RUN DEXT AT THE COMMAND PROMPT
(princ "\nPlease wait while DEXT processes the BOM Table...")
(defun *error* ( msg );error handler
(and old (mapcar 'setvar vars old))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(setq vars '("CMDECHO" "FILEDIA") old (mapcar 'getvar vars))
(mapcar 'setvar vars '(0 0));set variables
(setq dn (getvar "dwgname"));get filename ;GETS THE FILENAME SO IT CAN RESAVE THE FILE WHEN IT'S DONE RUNNING
(setq dp (getvar "dwgprefix"));get file path ; GETS THE PATH SO IT SAVES IT IN THE RIGHT PLACE
;(setq xls (vl-string-subst ".xls" ".dwg" dn))
(dos_copy "c:\\temp\\dext-orig.dxe" "c:\\temp\\dext.dxe");keep copy of dext.dxe fresh and up to date
;(dos_copy "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\Templates\\dext.xls" "c:\\temp\\dext.xls")
;(dos_copy "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\Templates\\dext.dwg" "c:\\temp\\dext.dwg")
(command "SAVEAS" "2010" (strcat "C:\\Temp" "\\" "dext.dwg") "YES");temporary directory for dummy dxe THIS IS WHERE IT SAVES YOUR DRAWING TO C:\TEMP
(command "-dataextraction" "c:\\temp\\dext.dxe" "YES" "-75,75,0");perform the data extraction, place the table at a specific location in drawing
;(command "_.DELAY" 7000);allows time for acad to write the xls file
;(dos_copy "c:\\temp\\dext.xls" (strcat dp "..\\misc\\" xls));copy excel sheet to misc folder in project directory
(command "SAVEAS" "2010" (strcat dp dn) "YES");restore dwg to original directory
(mapcar 'setvar vars old);return variables
(princ "\nDEXT has successfully created the Item List")
(princ);exit quietly
)