TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on August 20, 2009, 08:34:36 AM

Title: Using the Item Method when Interfacing with Excel
Post by: Lee Mac on August 20, 2009, 08:34:36 AM
I have been trying to work with Excel using Visual LISP, but my attempts have been pretty poor so far...

I cannot seem to get the "Item" method to work at all - I am trying to activate a specific Worksheet within a specific Workbook, (without the need to cycle through all the objects in a collection).

I have tried something like this, but keep getting "Error: Member not Found.":

Code: [Select]
(setq xlApp (vlax-get-or-create-object "Excel.Application"))

               (setq Sht (vlax-invoke
                            (vlax-get-property
                              (vlax-invoke
                                (vlax-get-property xlApp 'Workbooks)
                                "Add")
                              'Sheets)
                            'Item "Sheet1"))

Any help is appreciated.
Title: Re: Using the Item Method when Interfacing with Excel
Post by: pkohut on August 20, 2009, 09:21:31 AM
Took a bit thrashing, but got it figured out.

(defun c:abc (/)
  (setq xlApp (vlax-get-or-create-object "Excel.Application"))
  (setq xlWbks (vlax-get-property xlApp 'WorkBooks)) 
  (setq xlShts (vlax-get-property (vlax-invoke xlWbks "Add") 'Sheets))
  (setq xlItem (vlax-get-property xlShts "Item" "Sheet1"))
)
Title: Re: Using the Item Method when Interfacing with Excel
Post by: Lee Mac on August 20, 2009, 09:51:10 AM
Thanks Paul,

Ahh, so Item is a property... not a method  :ugly:

Cheers,

Lee