Results 1 to 9 of 9

Thread: GetExcel.lsp

  1. #1
    Member
    Join Date
    2009-12
    Posts
    19
    Login to Give a bone
    0

    Default GetExcel.lsp

    Hey guys,

    I'm trying to use getexcel.lsp (http://web2.airmail.net/terrycad/LISP/GetExcel.lsp) to export data from a title block to excel for a document transmittal then back into a drawing register in CAD. It all works fine except when Excel is opened or closed it crashes. The data is still transferred, but having to cancel the "Excel has encountered a problem..." error on every drawing that runs through a script is kind of defeating the purpose.

    Has anyone else experienced this issue and is there a fix? Is it simply an issue with the Office installation? I've tried it on more than 1 computer and get the same error.

    Thanks.

  2. #2
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    I'm not sure I fully understand your question, but I have 3 get excel programs that I use (1 for 32 bit, 1 for 64 bit, and 1 that uses open office instead of microsoft, its an eagle point thing), and if the excel file is open for any of them, it doesnt work properly.

  3. #3
    Member
    Join Date
    2009-12
    Posts
    19
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    Ok, I'll try be more clear.

    I'm running a 32 bit system, I didn't know there was a different lisp for 32 and 64 bit systems. Am I using the right one? (link in above post)

    I'm trying to write a routine that pulls information from a title block on a drawing and using the functions in getexcel to populate cells with this data in an already created excel document.

    Firstly using "getexcel" (GetExcel ExcelFile$ SheetName$ MaxRange$)
    and "getcell" (setq H30 (GetCell "H30")) etc.
    to find the first empty cell in a column to start populating.
    Once the getexcel function is passed it brings up the error "microsoft office has encountered a problem and needs to close". Then "getcell" functions as expected.

    Then to write the new data into the excel file I use "openexcel" (openexcel ExcelFile$ NIL NIL)
    and "putcell" (putcell DwgNameCell Title) etc.
    then "closeexcel" (closeexcel ExcelFile$)
    Once the openexcel function is passed. Then "putcell" functions as expected. Then "closeexcel" is passed and the error pops up again.

    In the end the data is written to the file but I can not get rid of these errors. It's easy enough to click through the errors, but when running it on 50 odd drawings it would be desirable to not have these errors.

    Hopefully this enough info. Any help on this would be greatly appreciated. Thanks.
    Last edited by jimmy_goodall; 2011-03-30 at 04:08 AM.

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    Quote Originally Posted by jimmy_goodall View Post
    Firstly using "getexcel" (GetExcel ExcelFile$ SheetName$ MaxRange$)
    and "getcell" (setq H30 (GetCell "H30")) etc.
    These appear to be fine.

    Quote Originally Posted by jimmy_goodall View Post
    to find the first empty cell in a column to start populating.
    Once the getexcel function is passed it brings up the error "microsoft office has encountered a problem and needs to close". Then "getcell" functions as expected.

    Then to write the new data into the excel file I use "openexcel" (openexcel ExcelFile$ NIL NIL)
    Here's where I *beleive* you make a mistake

    From GetExcel.lsp:

    ; OpenExcel - Opens an Excel spreadsheet
    ; Syntax: (OpenExcel ExcelFile$ SheetName$ Visible)
    ; Example: (OpenExcel "C:\\Folder\\Filename.xls" "Sheet1" nil)
    Quote Originally Posted by jimmy_goodall View Post
    and "putcell" (putcell DwgNameCell Title) etc.
    then "closeexcel" (closeexcel ExcelFile$)
    Once the openexcel function is passed. Then "putcell" functions as expected. Then "closeexcel" is passed and the error pops up again.

    In the end the data is written to the file but I can not get rid of these errors. It's easy enough to click through the errors, but when running it on 50 odd drawings it would be desirable to not have these errors.

    Hopefully this enough info. Any help on this would be greatly appreciated. Thanks.
    Having only skimmed GetExcel.lsp, I'm not sure I understand this snippet:

    Code:
    ...
      (if (setq *ExcelApp% (vlax-get-object "Excel.Application"))
       (progn
         (alert "Close all Excel spreadsheets to continue!")
         (vlax-release-object *ExcelApp%)(gc)
       );progn
     );if
      (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application"))
    ...
    ...If using vlax-get-or-create-object, and supplying the function an ExcelFIle$, SheetName$ arguments, I fail to understand why one would need to be alerted to "Close all Excel spreadsheets to continue"...?

    Sure this *may* be needed... *if* the supplied ExcelFIle$ argument were among the already open ExcelFiles, but that is not even checked for in the LISP.

    Not sure that this is your issue, but confusing to me none-the-less.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Member
    Join Date
    2009-12
    Posts
    19
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    The getexcel function still triggers the error so maybe it's time to do a clean install of office. I've looked at a lot of places on the net to do with GetExcel.lsp and I can't seem to find anyone with a similar problem.

    The openexcel function doesn't trigger the error. The sheet name can be passed as nil and the sheet the excel file was last open at is used. It's the closeexcel function that triggers the error.

    I though the alert was just giving you the option to close excel before the code releases it and does a garbage collection to close it immediately. I may be wrong though.

  6. #6
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    The website http://web2.airmail.net/terrycad that hosted AutoLISP Exchange, GetExcel and Getting Started with DCL Dialogs has been moved to the new domain https://autolisp-exchange.com . All programs and files are free to download and share. Just click on a button to view the program, then right-click and choose Save as...
    GetExcel is a general purpose function for Excel to AutoCAD and AutoCAD to Excel applications. Special credit to Gilles Chanteau from Marseille, France for his sub-functions ColumnRow, Alpha2Number and Number2Alpha. The error routine has been revised to work with scripts. The syntax for the functions are easy to follow, and include documentation of the conditions of each argument in the function headings.
    Last edited by Terry Cadd; 2020-04-28 at 06:10 AM. Reason: Special credit to Gilles Chanteau from Marseille, France

  7. #7
    Member
    Join Date
    2000-12
    Posts
    6
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    I was testing the GetExcel utility when I discovered that after reading an XLSX file, all instances of Excel are closed.

    I was testing with Windows 10 Pro, AutoCAD 2019, and Excel 2016.

    Is there any way to prevent all instances of Excel from being closed?

    Thank you for your time and attention. I look forward to your reply.


    Regards,
    Jerry

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    Quote Originally Posted by jberns View Post
    Is there any way to prevent all instances of Excel from being closed?
    Just close your working sheet and not the Excel object.

  9. #9
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: GetExcel.lsp

    Getexcel was written many years ago and has a few functions that could be improved, as Tharwat has suggested a close current workbook only, the same with GETCELL written around get all cells and then pull out value from a list rather than just get a cell. Re PUTCELL, I have added extra functions and so have a few others writing their own version of acad <--> Excel, I acknowledge the great help Getexcel.lsp provided.

    Others by RLX, Denton excel routines trying to find web link.

    Extra functions
    More checking what is open, none, matches filename
    Create new workbook
    Read current excel range
    Add worksheets

    Its a work in progress hence not posted.

    This may be helpful
    (vlax-invoke-method (vlax-get-property myxl "ActiveWorkbook") 'Close :vlax-False)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •