Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Writing to Excel with LISP

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1797 Views, 7 Replies

Writing to Excel with LISP

Hello all, I am trying to writing some data to an Excel (2002) spreadsheet using LISP (ACAD 2004). I know, I know, its much easier with VBA, but I unfortunately don't know VBA. So it's got to be LISP. I think I'm doing everything right up to the point where I send a variant array to an Excel range. ACAD gives me the error "error: Automation Error. Description was not provided." I'm missing something here. Can anybody help? either with the code below or by pointing me to a good resource that I can use to figure this out? Help, as always, is GREATLY appreciated. (vl-load-com) (if (not excm-open) (vlax-import-type-library :tlb-filename "C:/Program Files/Microsoft Office/Office10/Excel.exe" :methods-prefix "msxl-" :properties-prefix "msxl-" :constants-prefix "msxl-") ) (setq ExcelApp (vlax-get-or-create-object "Excel.Application") ExcelWBC (vlax-get-property ExcelApp 'WorkBooks) NewWB (vlax-invoke-method ExcelWBC 'add) );setq (vlax-put-property ExcelApp 'visible 1) (setq NewWS (vlax-get-property NewWB 'worksheets) NewWS# (vlax-get-property NewWS 'item wkst#) Start "A" End (if (< (/ (length (car lst)) 26) 1) (chr (+ 64 (length (car lst)))) (strcat (chr (+ 64 (/ (length (car lst)) 26))) (chr (+ 64 (fix (* 26 (- (/ (length (car lst)) 26.0) (/ (length (car lst)) 26)))))))) Range (strcat Start "1:" End "1") sfarray (vlax-make-safearray vlax-vbVariant (cons 1 (length (car lst)))) );setq (setq lst1 (mapcar '(lambda (x) (mapcar 'vlax-make-variant x)) lst)) (setq counter 1) (foreach n lst1 (vlax-safearray-fill sfarray n) (setq vsfarray (vlax-make-variant sfarray) oRng (msxl-get-range NewWS# Range) );setq (msxl-put-value oRng sfarray) ;;;;;;;;; This is where my problem is. (setq counter (1+ counter)) (setq Range (strcat "A" (itoa counter) ":" (substr range 4 1) (itoa counter))) (vlax-release-object oRng) );foreach ;; Release all object and close Excel. (vlax-release-object oRng) (vlax-release-object NewWS#) (vlax-release-object NewWS) (vlax-release-object NewWB) (msxl-saveas ExcelWBC fname nil nil nil nil nil nil) Fraser Atkinson CleatusSnow@magma.ca
7 REPLIES 7
Message 2 of 8
Speed_CAD
in reply to: Anonymous

Hi...

Look this:
http://discussion.autodesk.com/thread.jspa?threadID=322061
Mauricio Jorquera
Message 3 of 8
kozmos
in reply to: Anonymous

try KozMos OASis-XLS @
http://www.ikozmos.com
Message 4 of 8
Speed_CAD
in reply to: Anonymous

Hi kozmos...

OASis-XLS, it do not work. I don't know why

Un saludo de SpeedCAD... 🙂
CHILE
FORO: http://www.hispacad.com/foro
Mauricio Jorquera
Message 5 of 8
Anonymous
in reply to: Anonymous

MsXUtl01.LSP - Visual LISP ActiveX API for Excel 97, 2000 and XP Version 1.03 - 29/01/04 -- ________________________________________________ Marc'Antonio Alessi (TV) Italy (strcat "NOT a " (substr (ver) 8 4) " guru.") O.S. = XP Pro 2002 Ita - Sp.1 AutoCAD = 2004 Ita - Sp.1a ________________________________________________
Message 6 of 8
Anonymous
in reply to: Anonymous

error: LOAD failed: "UtlAutCd" I get this message when trying to load your MsXUtl01.LSP file. there must a file missing Thanks "Marc'Antonio Alessi" wrote in message news:405f2489_2@newsprd01... > MsXUtl01.LSP - Visual LISP ActiveX API for Excel 97, 2000 and XP > Version 1.03 - 29/01/04 > > -- > ________________________________________________ > > Marc'Antonio Alessi (TV) Italy > (strcat "NOT a " (substr (ver) 8 4) " guru.") > > O.S. = XP Pro 2002 Ita - Sp.1 > AutoCAD = 2004 Ita - Sp.1a > ________________________________________________ >
Message 7 of 8
kozmos
in reply to: Anonymous

what does the AutoCAD say about OASis-XLS not working?
Message 8 of 8
Anonymous
in reply to: Anonymous

My apologies, delete the first row in the file, it is a my utility function, not necessary, Marco -- > I get this message when trying to load your MsXUtl01.LSP file. there must a > file missing > Thanks >

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost