Author Topic: Editing an Excel file  (Read 1013 times)

0 Members and 1 Guest are viewing this topic.

civil.eng

  • Newt
  • Posts: 66
Editing an Excel file
« 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 :

Code: [Select]
  (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.

civil.eng

  • Newt
  • Posts: 66
Re: Editing an Excel file
« Reply #1 on: September 19, 2022, 04:15:32 AM »
Any help

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8696
  • AKA Daniel
Re: Editing an Excel file
« Reply #2 on: September 19, 2022, 05:06:10 AM »

dexus

  • Bull Frog
  • Posts: 207
Re: Editing an Excel file
« Reply #3 on: September 19, 2022, 05:54:59 AM »
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.