I'm trying to write a LISP routine where the values of an already selected ranged of cells in an already open excel workbook are iterated and read into the drawing. I have tried this:
Code:
(setq ^ExcelApp (vlax-get-object "Excel.Application"))
(setq ^WorkBook (vlax-get-property ^ExcelApp 'ActiveWorkBook))
(setq ^WorkSheet (vlax-get-property ^ExcelApp 'ActiveSheet))
(setq ^Selection (vlax-get-property ^ExcelApp 'Selection))
and this:
Code:
(setq ^ExcelApp (vlax-get-object "Excel.Application"))
(setq ^WorkBook (vlax-get-property ^ExcelApp "ActiveWorkBook"))
(setq ^WorkSheet (vlax-get-property ^ExcelApp "ActiveSheet"))
(setq ^Selection (vlax-get-property ^ExcelApp "Selection"))
In both case, the values for ^WorkBook, ^WorkSheet & ^Selection are nil.
If I run (vla-put-visible ^ExcelApp :vlax-true) after the vlax-get-object call, a second instance of excel with no workbooks open is displayed (which might explain the nil values). Can someone please show me how to capture the selected cells?
As always, any help is greatly appreciated.