TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: civil.eng on September 13, 2022, 03:28:07 PM
-
Hello everyone,
I have a subrutin to open an Excel file and add some changes into it, it works well when the excel file is visible, but changes not saved after closing it by using programmatically :
(setq f "D:\\262.csv")
(setq excel (vlax-get-or-create-object "Excel.Application"))
(vla-put-visible excel :vlax-true)
(setq workbooks (vlax-get-property excel 'workbooks))
(setq currworkbook (vlax-invoke-method workbooks 'open f))
(setq xlsheets (vlax-get-property currworkbook "Sheets"))
(setq xlsht (vlax-get-property xlsheets 'item 1))
(vlax-put-property xlsht 'name "Points")
(setq xlrng (vlax-get-property xlsht 'usedrange))
(setq xlcol (vlax-get-property xlrng 'columns))
(vl-catch-all-apply
'vlax-invoke-method
(list xlcol 'autofit)
)
(vlax-invoke-method workbooks 'Close :vlax-true)
(vlax-release-object workbooks)
(vlax-invoke-method excel 'Quit)
(vlax-release-object excel)
)
My aim is to open Excel file in a hidden way then making the changes and finally closing it automatically.
-
Any help
-
I didn't see a save, just close and quit.
https://learn.microsoft.com/en-us/office/vba/api/excel.workbook.save
-
When I try it I get a "Too many actual parameters" on the line: "(vlax-invoke-method workbooks 'Close :vlax-true)"
So I can't get the code to work, even when excel is opened.