Add sheet to excel workbook based on template

Add sheet to excel workbook based on template

Anonymous
Not applicable
712 Views
0 Replies
Message 1 of 1

Add sheet to excel workbook based on template

Anonymous
Not applicable

I would like to export a bill of materials from AutoCAD to an Excel workbook.

I know how to start excel, start a new workbook based on a template and how to export the BOM.

Now I would like to add a sheet based on a template to the workbook.

 

(setq xlsapp (vlax-get-or-create-object "Excel.Application")) ;; Start Excel
(vlax-put-property xlsapp "Visible" :vlax-true)
(setq workbooks (vlax-get xlsapp "workbooks"))
(setq WorkBook (vlax-invoke WorkBooks 'open templatefile)) ;; Start with template
(setq sheets (vlax-get workbook 'worksheets)) ;; get sheets collection

 

(setq newSheet (vlax-invoke sheets 'add )) ;; Add empty sheet. Works fine

(setq newSheet (vlax-invoke sheets 'add templateSheetfile)) ;; does NOT work.

 

What do I have to add to the function to make it work ?

 

 

0 Likes
713 Views
0 Replies
Replies (0)