Results 1 to 8 of 8

Thread: AutoCAD to Excel - error: Automation Error. Description was not provided

  1. #1
    Member
    Join Date
    2005-03
    Location
    Hyderabad, INDIA
    Posts
    26
    Login to Give a bone
    0

    Unhappy AutoCAD to Excel - error: Automation Error. Description was not provided

    While updating the data from AutoCAD to Excel I am getting message.
    ; error: Automation Error. Description was not provided.

    Can anybody suggest me to overcome this

    I am using AutoCAD Map 6.0 and Microsoft Excel 2002(10.2614.3501)SP-1

    and I tried like this...

    Code:
    ;----------------------------------------------------------------------------------------------------------------------;
    ; Routine to update data from autocad to excel.
    ;----------------------------------------------------------------------------------------------------------------------;
    (defun C:Uv
    	  ()
    	  (if (setq excelObj (vlax-get-object "Excel.Application"))
           	  (if (169::ImportExcelLibrary (vlax-get-property excelObj 'Path))
    	  (progn
    	  (setq bookObj  (vlax-get-property excelObj 'ActiveWorkBook)
    		sheetObj (ExcelP-get-ActiveSheet bookObj)
    		rangeObj (ExcelP-get-Range sheetObj "A1")
    	  );setq
                      ;********** Error Position**************
    	  (ExcelP-put-Value rangeObj "Sample Text")
    	  ; error: Automation Error. Description was not provided.
    
    	  (vlax-release-object sheetObj)
    	  (vlax-release-object bookObj)
    	  (vlax-release-object excelObj)
    	  );progn
    	  );if
    	  );if
    (princ)
    );defun
    Code:
    ;----------------------------------------------------------------------------------------------------------------------;
    ; Function to import Excel library.
    ;----------------------------------------------------------------------------------------------------------------------;
    (defun 169::ImportExcelLibrary
    	  (libraryPath)
      	  (if (null(member "EXCELP-GET-ACTIVESHEET" (atoms-family 1)))
    	  (vlax-import-type-library :tlb-filename (strcat libraryPath "Excel.exe")
    	    			    	:methods-prefix "ExcelM-"
    	    			        :properties-prefix "ExcelP-"
    	    			        :constants-prefix "ExcelC-")
    	  T
    	  );if
    );defun
    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Opie; 2006-11-01 at 02:23 PM. Reason: [CODE] tags added, see Moderator Action

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    Try
    (ExcelP-put-Value2 rangeObj "Sample Text")

    : ) Happy Computing !

    kennet

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    Try this

    (setq excelObj (vlax-get-object "Excel.Application.10"))

    Also here is a routine that I use that works for importing excel data to a list.

    Peter
    Attached Files Attached Files

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    Quote Originally Posted by peter
    . . .Also here is a routine that I use that works for importing excel data to a list.

    Peter
    Peter, do you have a way to kill the EXCEL.EXE process after your routine is finished ?
    otherwise Excel is still running until you exit AutoCAD
    you can see that in the [Ctrl+Alt+Delete] Program Manager, tab Processes.

    : ) Happy Computing !

    kennet

  5. #5
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    Try this revised version.

    Peter
    Attached Files Attached Files

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    Quote Originally Posted by peter
    Try this revised version.

    Peter
    No, Excel is still active until I exit AutoCAD , please see attachment

    BTW typo at this line
    (errortrrap '(xlm-close objWBook))
    (errortrap '(xlm-close objWBook))

    : ) Happy Computing !

    kennet
    Attached Images Attached Images

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

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    This has worked for me as you want:

    Code:
    (defun EXD (/ ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)
    
      (vl-load-com)
      (setq	FilePath (getfiled "Select Excel file to read :"
    			   (getvar "dwgprefix")
    			   "xls"
    			   16
    		 )
      )
    
      (setq ShtNum (getint "\nEnter sheet number : \n"))
    
      (setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
      (vla-put-visible ExcelApp :vlax-true)
      (setq	Wbk (vl-catch-all-apply
    	      'vla-open
    	      (list (vlax-get-property ExcelApp "WorkBooks") FilePath)
    	    )
      )
      (setq	Sht (vl-catch-all-apply
    	      'vlax-get-property
    	      (list (vlax-get-property Wbk "Sheets")
    		    "Item"
    		    ShtNum
    	      )
    	    )
      )
      (vlax-invoke-method Sht "Activate")
      (setq	UsdRange (vlax-get-property Sht 'UsedRange)
    	ExcData	 (vlax-safearray->list
    		   (vlax-variant-value
    		     (vlax-get-property UsdRange 'Value)
    		   )
    		 )
      )					;or Value2
      (setq
        ExcData (mapcar
    	      (function (lambda (x) (mapcar 'vlax-variant-value x)))
    	      ExcData
    	    )
      )
    
      (vl-catch-all-apply
        'vlax-invoke-method
        (list Wbk "Close")
      )
    
      (vl-catch-all-apply
        'vlax-invoke-method
        (list ExcelApp "Quit")
      )
    
      (mapcar
        (function
          (lambda (x)
    	(vl-catch-all-apply
    	  (function (lambda ()
    		      (progn
    			(if (not (vlax-object-released-p x))
    			  (progn
    			    (vlax-release-object x)
    			    (setq x nil)
    			  )
    			)
    		      )
    		    )
    	  )
    	)
          )
        )
    
        (list UsdRange Sht Wbk ExcelApp)
      )
    
      (gc)
      (gc)
      ExcData
    
    )
    ;  CaLL :
    ; (setq somedata (exd))
    ~'J'~

  8. #8
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: AutoCAD to Excel - error: Automation Error. Description was not provided

    peter and fixo . . .the (gc) fixed it !

    When I put (gc) secondlast in Peters code, Excel will quit . . .
    Code:
    |
    |
    |
    (gc)
     (if lstOfSublists lstOfSublists)
    )
    : ) Happy Computing !

    kennet

Similar Threads

  1. Replies: 9
    Last Post: 2015-05-07, 10:35 PM
  2. AutoCad and Excel VBA Run time error
    By mklindquist370941 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2013-11-08, 03:46 PM
  3. Replies: 5
    Last Post: 2013-10-16, 05:39 PM
  4. Replies: 2
    Last Post: 2009-09-17, 01:53 PM
  5. Replies: 6
    Last Post: 2007-05-02, 11:39 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
  •