Message 1 of 14
How to delete the sheet in Excel?

Not applicable
12-09-2015
02:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I would delete the sheet in Excel.
Can anyone help?
(defun c:pol ( / Excel XlsFile WorkSheets SelSht ShtName) (setq Excel (vlax-get-or-create-object "Excel.Application") XlsFile (vl-catch-all-apply 'vla-open (list (vlax-get-property Excel "WorkBooks") "c:\temp\test.xls"))) (vlax-invoke-method XlsFile "Activate"); to activate the opened document (setq WorkSheets (vl-catch-all-apply 'vlax-get-property (list XlsFile "Worksheets"))) (setq SelSht (vl-catch-all-apply 'vlax-get-property (list WorkSheets "Item" 2))) (setq ShtName (vla-get-Name SelSht)) ; =>> Here I want to delete this sheet -> ShtName (vl-catch-all-apply 'vlax-invoke-method (list XlsFile "Save")) (vl-catch-all-apply 'vlax-invoke-method (list XlsFile "Close")) (vl-catch-all-apply 'vlax-invoke-method (list Excel "Quit")) (mapcar '(lambda (x) (vl-catch-all-apply '(lambda () (progn (vlax-release-object x) (setq x nil))))) (list Excel XlsFile WorkSheets SelSht) ) )
Jerzy