Autocad export to excel works fine with Office 2010 but not with 2016

Autocad export to excel works fine with Office 2010 but not with 2016

C.Utzinger
Collaborator Collaborator
1,231 Views
4 Replies
Message 1 of 5

Autocad export to excel works fine with Office 2010 but not with 2016

C.Utzinger
Collaborator
Collaborator

HI

I need a little hand with this part of my routine.

I can export to Excel 2010 but not to 2016.

The problem seems to be when the routine opens the file.

Because when the file is already open it works, the data is written in the this file and the routine opens a empty second one.

 

I don't know if this is enougth Information... please help

 

(defun LM:Open ( target / Shell result )
  
  (setq Shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
  (setq result
    (and (or (eq 'INT (type target)) (setq target (findfile target)))
      (not
        (vl-catch-all-error-p
          (vl-catch-all-apply 'vlax-invoke (list Shell 'Open target))
        )
      )
    )
  )
  (vlax-release-object Shell)
  result
)


(defun xls ( Data-list Data-list2 Data-list3 ColHide Name_list pnumber filename / *Aplexcel* *books-colection* Currsep
             *excell-cells* *new-book* *sheet#1* *sheet-collection* col cols iz_listo row cell file standort username)
  (defun Letter (N / Res TMP)
    (setq Res "")
    (while (> N 0)
    (setq TMP (rem N 26)
          TMP (if (zerop TMP)(setq N (1- N) TMP 26) TMP)
          Res (strcat (chr (+ 64 TMP)) Res)  N   (/ N 26))) Res)

  (setq *AplExcel* (vlax-get-or-create-object "Excel.Application"))

  (setq file (cond ((= Typ. "COMAX") (if (findfile filename)(findfile filename)(findfile "COMAX_Vorlage.xltx")))
		   ((= Typ. "FERBOX")(if (findfile filename)(findfile filename)(findfile "FERBOX_Vorlage.xltx")))
                   ((= Typ. "EBEA")(if (findfile filename)(findfile filename)(findfile "EBEA_Vorlage.xltx")))
		   ((= Typ. "ACINOXplus")(if (findfile filename)(findfile filename)(findfile "ACINOXplus_Vorlage.xltx")))))

  (LM:Open file)
0 Likes
Accepted solutions (1)
1,232 Views
4 Replies
Replies (4)
Message 2 of 5

C.Utzinger
Collaborator
Collaborator

OK

It seems that Excel does not open properly the file, it is inactive or something like that.

0 Likes
Message 3 of 5

C.Utzinger
Collaborator
Collaborator

I think the Problem is in the following part that does not work correctly with Office 2016.

Any Idea?

    (setq *New-Book*  (vlax-get-property *AplExcel* "ActiveWorkbook")
	  *Books-Colection*  (vlax-get-property *AplExcel* "Workbooks")
          *Sheet-Collection* (vlax-get-property *New-Book* "Sheets")
          *Sheet#1*     (vlax-get-property *Sheet-Collection* "Item" 1))
0 Likes
Message 4 of 5

C.Utzinger
Collaborator
Collaborator
Accepted solution

I changed the Lee Mac function to this one and now it works:

 

(defun OpenExcel (ExcelFile$ SheetName$ Visible / Sheet$ Sheets@ Worksheet)
  (if (= (type ExcelFile$) 'STR)
    (if (findfile ExcelFile$)
      (setq *ExcelFile$ ExcelFile$)
      (progn
        (alert (strcat "Excel file " ExcelFile$ " not found."))
        (exit)
      );progn
    );if
    (setq *ExcelFile$ "")
  );if
  (gc)
  (if (setq *ExcelApp% (vlax-get-object "Excel.Application"))
    (progn
      (vlax-release-object *ExcelApp%)(gc)
    );progn
  );if
  (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application"))
  (if ExcelFile$
    (if (findfile ExcelFile$)
      (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$)
      (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add)
    );if
    (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add)
  );if
  (if Visible
    (vla-put-visible *ExcelApp% :vlax-true)
  );if
  (if (= (type SheetName$) 'STR)
    (progn
      (vlax-for Sheet$ (vlax-get-property *ExcelApp% "Sheets")
        (setq Sheets@ (append Sheets@ (list (vlax-get-property Sheet$ "Name"))))
      );vlax-for
      (if (member SheetName$ Sheets@)
        (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets")
          (if (= (vlax-get-property Worksheet "Name") SheetName$)
            (vlax-invoke-method Worksheet "Activate")
          );if
        );vlax-for
        (vlax-put-property (vlax-invoke-method (vlax-get-property *ExcelApp% "Sheets") "Add") "Name" SheetName$)
      );if
    );progn
  );if
  (princ)
);defun OpenExcel
0 Likes
Message 5 of 5

Anonymous
Not applicable

I interesting to know if there is at Autocad convertion like from draw to excel image PDF ,or power point which i can submit a presentation i can convert to one of those app-s .

 

 

Thank you 

0 Likes