Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Excel 2007 with acad 2010

  1. #1
    I could stop if I wanted to
    Join Date
    2001-07
    Posts
    319
    Login to Give a bone
    0

    Default Excel 2007 with acad 2010

    Hello,
    I'm updating our routines and one of them is about Excel.
    I have the following list
    Code:
    (("E19" . "335") ("F19" . "334") ("G19" . "336") ("H19" . "") ("T19" . "??") 
    ("E18" . "338") ("F18" . "337-2") ("G18" . "339") ("H18" . "") ("T18" . "??") 
    ("AC18" . "??") ("AB18" . "??") ("E17" . "D4") ("F17" . "555") ("G17" . "05") 
    ("H17" . "") ("T17" . "??") ("E16" . "d3") ("F16" . "340") ("G16" . "01") 
    ("H16" . "") ("T16" . "??") ("AC16" . "??") ("AB16" . "??") ("E15" . "6") 
    ("F15" . "666") ("G15" . "02") ("H15" . "") ("T15" . "??") ("I5" . "207135999") 
    ("I5" . "TEST LINK P&ID ITEMLIST"))
    the first member is the cell number whereas the second one is the content of the cell.
    Would you be kind to give me a hint to get it working.
    Is it still necessary to look for the excel.olb?
    THanks for any advice

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    Wait until tomorrow if you can,
    I will try
    Just you have to define sheet name and file name
    before, coz this data is not enough
    Or do you want to write it into the newly created xls file?
    Oops, nap time is here...

  3. #3
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    Can't sleep...
    Code:
    (defun C:wdx(/ cells data filename sheetname xlapp xlbook xlbooks xlcells xlsheet xlsheets)
      (setq filename "C:\\Test\\blah.xls");<--change
      (setq sheetname "Sheet1");<--change
    (setq data
    '(("E19" . "335") ("F19" . "334") ("G19" . "336") ("H19" . "") ("T19" . "??") 
    ("E18" . "338") ("F18" . "337-2") ("G18" . "339") ("H18" . "") ("T18" . "??") 
    ("AC18" . "??") ("AB18" . "??") ("E17" . "D4") ("F17" . "555") ("G17" . "05") 
    ("H17" . "") ("T17" . "??") ("E16" . "d3") ("F16" . "340") ("G16" . "01") 
    ("H16" . "") ("T16" . "??") ("AC16" . "??") ("AB16" . "??") ("E15" . "6") 
    ("F15" . "666") ("G15" . "02") ("H15" . "") ("T15" . "??") ("I5" . "207135999") 
    ("I5" . "TEST LINK P&ID ITEMLIST")))
    
      (setq	xlapp	   (vlax-get-or-create-object "Excel.Application")
    	xlbooks  (vlax-get-property xlapp 'Workbooks)
    ;;;	xlbook	   (vlax-invoke-method xlbooks 'Add);<-- for new file
    	xlbook (vl-catch-all-apply
    	      'vla-open
    	      (list xlbooks filename)
    	    )
     
    	xlsheets (vlax-get-property xlbook 'Sheets)
    	xlsheet	   (vlax-get-property xlsheets 'Item sheetname)
    	xlcells	   (vlax-get-property xlsheet 'Cells)
    	)
      
      
    (vla-put-visible xlapp :vlax-true)
    (vl-catch-all-apply 'vlax-put-property (list xlapp 'ScreenUpdating :vlax-false))
    (foreach item data
      (setq xlrange (vl-catch-all-apply
        'vlax-get-property  (list xlcells 'Range (car item))))
    (vl-catch-all-apply
        'vlax-put-property
        (list xlrange 'Value2 
    	 (vlax-make-variant
    	   (cdr item) 8)))
      )
    
    
    (vl-catch-all-apply 'vlax-put-property (list xlapp 'screenupdating :vlax-true))
    (vlax-invoke-method
        xlbook
        'SaveAs
        filename 
        -4143
        nil
        nil
        :vlax-false
        :vlax-false
        1
        2
      )
    (vlax-invoke-method
        xlbook 'Close)
    (vlax-invoke-method
        xlapp 'Quit)
      (mapcar '(lambda (x)
    	     (vl-catch-all-apply
    	       '(lambda	()
    		  (vlax-release-object x)
    		)
    	     )
    	   )
    	  (list xlcells xlsheet xlsheets xlbook xlbooks xlapp)
      )
      (setq  xlapp nil)
      (gc)(gc)(gc)
      (princ)
      )
    (prompt "\n\t\t***\tStart command with WDX\t***\n")
    (princ)
    
    (or (vl-load-com)
        (princ)     )
    Tested on Excel 2007 (student release), AutoCAD 2010, Win7

    ~'J'~

  4. #4
    I could stop if I wanted to
    Join Date
    2001-07
    Posts
    319
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    Thanks a lot fixo,
    I hoop that it wasn't my question that kept you awake

    shouldn't the objects be released

    Code:
    (vlax-release-object xlsheets)
    ...
    just saw it..
    How can I navigate between all sheets?
    Thanks again
    Last edited by clovis; 2012-01-19 at 08:04 AM.

  5. #5
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    I just thought it was urgently for you
    Cheers

  6. #6
    I could stop if I wanted to
    Join Date
    2001-07
    Posts
    319
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    You're right, I have until the end of the week to make things work. Next week I'm working on a project and thus won't have any time to work on automate.
    Just need to find out how to switch between sheets
    Thanks

  7. #7
    I could stop if I wanted to
    Join Date
    2001-07
    Posts
    319
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    After a better reading of your file I figure it out
    Thanks

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    You're welcome,
    sorry for the belating, I have
    started to learn English on TV channel now
    It will take a lot of time...
    If it will be an extra urgent case you might be want to
    send me PM
    Guess, maybe I wiill be busy next few weeks

  9. #9
    I could stop if I wanted to
    Join Date
    2001-07
    Posts
    319
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    Hi
    this method doesn't work for me
    Code:
    (vlax-invoke-method
        xlbook
        'SaveAs
        filename 
        -4143
        nil
        nil
        :vlax-false
        :vlax-false
        1
        2
      )
    using those ones makes it work
    Code:
    	(vlax-invoke-method Xlbook 'save)
    	(vlax-invoke-method Xlbook 'close :vlax-True xlFile)
    could you explain the -4143?
    Anyways, I got it now so thanks for sharing!

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Excel 2007 with acad 2010

    could you explain the -4143?
    Anyways, I got it now so thanks for sharing!
    Hint:
    Open VBA Editor in Excel, then look at SaveAs method in the Excel Help
    Then copy the desired argument starting with "xl", open Immediate window inside
    the editor, then paste in this window your argument preceded with ? symbol:
    ?xlblahbla
    then press Enter
    You will see result as number below, that's all
    another possible option to pass file name of Excel file to SaveAs expression is
    to write them without extension, e.g. "C:\\MyFolder\\MyExcelFille"
    Not sure about if it will be work on your release though

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 2013-10-16, 05:39 PM
  2. ACAD 2008 vba compatible with acad 2010?
    By Ammon in forum VBA/COM Interop
    Replies: 3
    Last Post: 2011-01-12, 10:27 PM
  3. Mtext Issues Acad 2007 to Acad 2009
    By Eddy B in forum AutoCAD General
    Replies: 11
    Last Post: 2009-02-13, 12:37 PM
  4. Replies: 2
    Last Post: 2007-01-30, 10:51 AM
  5. ACAD 2007 saving down to ACAD 2004 - ARX Error: eDuplicateKey
    By Dicastaddict1 in forum AutoCAD General
    Replies: 4
    Last Post: 2006-10-26, 03:35 PM

Posting Permissions

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