CLOSE ALL EXCEL SPREADSHEETS TO CONTINUE

Hi
I am using an Autocad Lisp to update multiple Titleblock Revision and Change Numbers.
It works OK except this message appears at every drawing that updates and I have to click OK
"CLOSE ALL EXCEL SPREADSHEETS TO CONTINUE"
Do I need to change the Lisp so this will close automatically ?
Thanks

Comments

  • Hi Andrew,
    it is hard to give feedback without seeing the script or at least pars of it. Do you open the excel file during the script? Where is the data written? In a table? Then you might consider using a datalink between table and excel and you would not need a script.
  • Thanks for your reply Piet.
    Yes , the excel is opened during the script.
    I did not write the lisp.
    The lisp works perfectly in Autocad , only in Bricscad does this message appear
  • Is it Getexcel.lsp your using ? I wrote my own excel functions to avoid this type of error message, checking what is open or which worksheet is being used. Its not really a debugged package at this stage needs some more work and testing.
  • Hi AlanH ,
    Appreciate your reply , yes , the lisp is "Getexcel.lsp" , release 4.
    Any chance of getting a copy of your updated Lisp please ?
  • ALANH
    edited June 20
    My version of excel.lsp uses some of the stuff out of getexcel, there were a couple of things I did not like so wrote my own getcell. Includes the great functions by Gile.

    I added get a selected range handy when asking user to select a range. You do an alert asking user to select range in excel then press Ok in Acad.

    I have attached it but it is a work in progress, you have to appreciate it needs the functions to be done in correct order depending on circumstances.

    There are a few others also playing with excel functions. Look at this one also by denon detering excel functions. alx.zip

  • Thanks very much again.
    I haven't had much experience at lisps, and the one I am using was created by someone else.
    Their response was to get rid of Bricscad and buy Autocad as thee is no issue when run in Autocad.
    Thanks for the lisps , I will have a look and see what happens.
  • this is the lisp I have been using
  • I use Bricscad for majority of programming so not sure why your getexcel is not working properly.

    If you explain more what it is your trying to do I can look into testing with my or Denton version. I have Denton contact email. I know the excel is open was a problem with getexcel I thought in Acad as well.

    The check in the code open already I thought was here.

    (or (setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
    )

    Explain excel open Y or N
    Open excel file ?
    Just use current ?
    Open a file but is it open already

    Need to look at current circumstances. Just a few of the questions.
  • Thanks Alan ,
    Yes , its strange how it works in Autocad but not Bricscad.
    The function of the Lisp is to open each drawing sheet that I load into ScriptPro ,and using the associated excel spreadsheet, updates the Revision and Change Number in the Titleblock.
    The problem is each drawing that opens , I have to click on a dialogue box "close all excel spreadsheets to continue". When run in Autocad , this does not happen.
    Thanks
    Andrew
  • That was the bug I have seen I think the couple of lines I posted helps.
  • thanks , you mean these lines ?

    (or (setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
    )

    Explain excel open Y or N
    Open excel file ?
    Just use current ?
    Open a file but is it open already
  • The questions after the code is what is current excel state and the code needs to take it into account.
  • OK , Thanks , writing Lisp codes is not my thing.
    is there any tutorials you know of that could help me correct the Lisp please ?
    I could try myself , do i need to somehow add a line telling the Excel to close ?
    After this line - (setq myxl (vlax-get-or-create-object "excel.Application")) ?
  • You would need say 3 close types, Save, Saveas & Quit. That is why I started to write my own defuns. The AH:ex is a variable about save etc.

    (defun closeexcel ( / )
    (if (= ah:ex "T")
    (vlax-invoke-method (vlax-get-property myxl "ActiveWorkbook") 'Close :vlax-False)
    (vlax-invoke-method (vlax-get-property myxl "ActiveWorkbook") "SaveAs" filename -4143 "" "" :vlax-false :vlax-false nil )
    )

    ; (vlax-invoke-method myxl 'Quit)

    (if (not (vlax-object-released-p myRange))(progn(vlax-release-object myRange)(setq myRange nil)))
    (if (not (vlax-object-released-p mySheet))(progn(vlax-release-object mySheet)(setq mySheet nil)))
    (if (not (vlax-object-released-p myBook))(progn(vlax-release-object myBook)(setq myBook nil)))
    (if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil)))
    )
  • Awesome , thanks, I will give this a try.
    Much appreciated.
  • Andrew
    edited July 4
    Hi
    I added your lisp to the lisp like below but still same close excel alert appears -

    ; CloseExcel - Closes Excel spreadsheet
    ; Arguments: 1
    ; ExcelFile$ = Excel saveas filename or nil to close without saving
    ; Syntax examples:
    ; (CloseExcel "C:\\Temp\\Temp.xls") = Saveas C:\Temp\Temp.xls and close
    ; (CloseExcel nil) = Close without saving
    ;-------------------------------------------------------------------------------
    (defun closeexcel ( / )
    (if (= ah:ex "T")
    (vlax-invoke-method (vlax-get-property myxl "ActiveWorkbook") 'Close :vlax-False)
    (vlax-invoke-method (vlax-get-property myxl "ActiveWorkbook") "SaveAs" filename -4143 "" "" :vlax-false :vlax-false nil )
    )

    ; (vlax-invoke-method myxl 'Quit)

    (if (not (vlax-object-released-p myRange))(progn(vlax-release-object myRange)(setq myRange nil)))
    (if (not (vlax-object-released-p mySheet))(progn(vlax-release-object mySheet)(setq mySheet nil)))
    (if (not (vlax-object-released-p myBook))(progn(vlax-release-object myBook)(setq myBook nil)))
    (if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil)))
    )
    );defun CloseExcel

  • Hi, did you play with these properties?

    Application.Interactive = False
    Application.DisplayAlerts = False
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!