Jump to content

Recommended Posts

Posted

Hi guys, I open excel file and then close it after edit via autolisp, it works correctly , but Changes don't save :

 

  (vlax-invoke-method wbk 'Close :vlax-true)
  (vlax-release-object wbk)
  (vlax-invoke-method excel 'Quit)
  (vlax-release-object excel)

 

can anyone help me?

Posted

(vl-catch-all-apply 'vlax-invoke-method (list wbk "Save"))) ?

 

  • Like 1
Posted

Yes, I put put that code but it doesn't save again

 

(vl-catch-all-apply
    'vlax-invoke-method
    (list wbk "Save")
  )


  (vlax-invoke-method wbk 'Close :vlax-true)
  (vlax-release-object wbk )
  (vlax-invoke-method excel 'Quit)
  (vlax-release-object excel)

 

Posted (edited)

hard to tell without sample from your lisp and your excel workbook. You could try to find out if saving works at all


(if (vl-catch-all-error-p (setq err (vl-catch-all-apply 'vlax-invoke-method (list wbk "Save"))))
    (prompt (strcat "\nError: " (vl-catch-all-error-message err))))

 

make sure you are saving the workbook and not just the active sheet

 

maybe this is a good read : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-and-close-excel-worksheet/td-p/864033

 

there a many excel posts on this forum (Bigal even wants to give them their own seperate forum 😄)

 

GetExcel.lsp

Edited by rlx
  • Like 1
Posted

Thank you for the lisp, I have another question, how can I find last row in column, for example column "A" ? (via autolisp)

Posted

in my loop generator app (LG) I use :


(if (and LG-ExcelApp LG-ExcelWorkBook LG-ExcelSheet)
    (progn
      (setq CurRegion (vlax-get-property  LG-ExcelSheet 'UsedRange))
      (setq LG-XlsMaxRow (vlax-get-property (vlax-get-property CurRegion "Rows") "Count"))
      (setq LG-XlsMaxCol (1+ (vlax-get-property (vlax-get-property CurRegion "Columns") "Count"))))))


just subst. your names for the excel-app / workbook / sheetname

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...