Author Topic: Connect with excel  (Read 2245 times)

0 Members and 1 Guest are viewing this topic.

josan

  • Mosquito
  • Posts: 15
Connect with excel
« on: December 18, 2013, 11:27:46 AM »
Hello, good day ... I am testing various functions to open and write to a excel sheet data from a list ... I copied some features ... but .... to open files with a script and execute the function "IniciaExcel" excel file is opened, data is written and the dwg file is closed. When I open other dwg file the excel connection is lost and I can not write data ... if I go back to start "IniciaExcel" another excel file is open and no longer serves me.
As I can keep the connection open and write to the same file?
Thank you ...
Thank you ...

Code: [Select]
(defun IniciaExcel ()
(setq *AplExcel* (vlax-get-or-create-object "excel.application")
*ColeccionLibros* (vlax-get-property *AplExcel* "Workbooks")
*NuevoLibro* (vlax-invoke-method *ColeccionLibros* "add")
*ColeccionHojas* (vlax-get-property *NuevoLibro* "sheets")
*Hoja1* (vlax-get-property *ColeccionHojas* "Item" 1)
*CeldasExcel* (vlax-get-property *Hoja1* "Cells")
)
(vla-put-visible *AplExcel* :vlax-true)
)
Code: [Select]
(defun TerminaExcel  ()
(vlax-release-object *CeldasExcel*)
(vlax-release-object *Hoja1*)
(vlax-release-object *ColeccionHojas*)
(vlax-release-object *NuevoLibro*)
(vlax-release-object *ColeccionLibros*)
(vlax-release-object *AplExcel*)
)
Code: [Select]
(defun Lista>Excel ()
(vl-load-com)
(if (= cent 0)
(progn
(setq list:tit:xls (list "No. Isometrico:" "Edicion:" "Fecha Edicion" "Revision" "Descripcion"
"Fecha Revision" "Revisado Por" "Vo.Bo." "Aprobado1" "Aprobado2" "Dibujo Elaborado"
"Fecha:" "Dibujo" "Proyecto" "Reviso" "Coordino" "Aprobo" "No. Proyecto" "Lugar"
"Numero Plano" "Rev." "Nombre Plano" "Nombre1" "Nombre2" "Nombre3"))
(IniciaExcel)
(setq cont 1)
(repeat 25
(DatoCelda cont 1 (nth (- cont 1) list:tit:xls))
(setq cont (+ cont 1))
)
(setq n (+ n 1))
(mas:datX)
(setq cent 1)
;(TerminaExcel)
)
(progn
(setq n (+ n 1))
(mas:datX)
(setq cent 1)
)
)
)

list:xls.- It is a list that comes from dwg and data that can vary in content ....

fixo

  • Guest
Re: Connect with excel
« Reply #1 on: December 18, 2013, 12:14:36 PM »
Try to find appropriate function within this library:
http://www.theswamp.org/index.php?topic=38450.msg466989#msg466989

josan

  • Mosquito
  • Posts: 15
Re: Connect with excel
« Reply #2 on: December 18, 2013, 12:23:07 PM »
Thanks Fixo.
I will sit to read .....