excel to acad

Discussion in 'AutoCAD' started by jackie, Jan 26, 2004.

  1. jackie

    jackie Guest

    While in Acad, I want to get the value of the activecell. Some how it is not
    working. Pls help.
    As shown below, var1 is accessible, but var2 is not?

    Dim xlApp As Object
    dim var1 as integer
    dim var2 as integer
    Set xlApp = GetObject(, "Excel.Application")
    var1=xlApp.ActiveWorkbook.ActiveSheet.cells(4, 4).Value ' this works

    '**************************************
    var2=xlApp.ActiveWorkbook.ActiveSheet.activecell.Value ' this does not work
    'Above line not working



    Thanks
     
    jackie, Jan 26, 2004
    #1
  2. jackie

    Norman Yuan Guest

    Worksheet does not have "ActiveCell" property, while Excel.Application
    objecd does. So, it seems to be:

    var2=xlApp.ActiveCell.Value ' this does not work

    You may have to be careful to make sure the correct Worksheet is currently
    active when you try to get Application.ActiveCell's value. Also, Since you
    use GetObject() to catch an existing Excel Application, if it is opened by
    user, the ActiveCell may be empty, or be a range of cells, so the Value
    could be empty, or an array. In this case, you'd better declare var1, var2
    as Variant, then use VarType() to verify what value is in it.
     
    Norman Yuan, Jan 27, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.