Results 1 to 3 of 3

Thread: Import selected cells from open excel workbook

  1. #1
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Import selected cells from open excel workbook

    I'm trying to write a LISP routine where the values of an already selected ranged of cells in an already open excel workbook are iterated and read into the drawing. I have tried this:

    Code:
    (setq ^ExcelApp   (vlax-get-object "Excel.Application"))
    (setq ^WorkBook  (vlax-get-property ^ExcelApp 'ActiveWorkBook))
    (setq ^WorkSheet (vlax-get-property ^ExcelApp 'ActiveSheet))
    (setq ^Selection (vlax-get-property ^ExcelApp 'Selection))
    and this:
    Code:
    (setq ^ExcelApp   (vlax-get-object "Excel.Application"))
    (setq ^WorkBook  (vlax-get-property ^ExcelApp "ActiveWorkBook"))
    (setq ^WorkSheet (vlax-get-property ^ExcelApp "ActiveSheet"))
    (setq ^Selection (vlax-get-property ^ExcelApp "Selection"))
    In both case, the values for ^WorkBook, ^WorkSheet & ^Selection are nil.

    If I run (vla-put-visible ^ExcelApp :vlax-true) after the vlax-get-object call, a second instance of excel with no workbooks open is displayed (which might explain the nil values). Can someone please show me how to capture the selected cells?

    As always, any help is greatly appreciated.
    Last edited by Opie; 2020-02-10 at 01:55 PM. Reason: [code] tags added

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Import selected cells from open excel workbook

    Have you searched the AutoLISP forum for Excel examples? I am fairly certain Excel has been discussed in the past.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

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

    Default Re: Import selected cells from open excel workbook

    Have a look at this an example excel lisp
    Attached Files Attached Files

Similar Threads

  1. Grouped schedules - non-empty cells in different color as empty cells
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2015-12-14, 01:33 PM
  2. 2013: Revit MEP Student Guide Workbook
    By Ehsan in forum Revit MEP - General
    Replies: 0
    Last Post: 2013-03-18, 01:47 PM
  3. Replies: 4
    Last Post: 2007-05-08, 11:50 AM
  4. Import excel cells within Revit schedule
    By valamar2005-site in forum Revit - API
    Replies: 7
    Last Post: 2005-07-02, 03:28 AM

Posting Permissions

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