Author Topic: Excel.Application error on AutoCAD/Excel 2013  (Read 3721 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Excel.Application error on AutoCAD/Excel 2013
« on: May 22, 2015, 10:06:24 AM »

Scenario: Windows 8.1 - Excel 2013 (15)
Code - Auto/Visual Lisp: [Select]
  1. ; Function   : MsX_TypeLib
  2. ; Description: Returns typelib (olb) file for either Excel 97, 2000, XP or >=2003
  3. ;
  4. (defun MsX_TypeLib2 ( / XlsPat MSOVer)
  5.   (setq XlsPat
  6.     (vl-registry-read
  7.       (strcat  "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" "Excel.exe")
  8.       "Path"
  9.     )
  10.   )
  11.   (cond
  12.     ( (< 9 (atoi (setq MSOVer (substr (vl-filename-base (vl-filename-directory XlsPat)) 7))))
  13.       (list XlsPat "Excel.exe"  MSOVer)
  14.     )
  15.     ( (vl-file-systime (strcat XlsPat "Excel9.olb" ))
  16.       (list XlsPat "Excel9.olb" MSOVer)
  17.     )
  18.     ( (vl-file-systime (strcat XlsPat "Excel8.olb" ))
  19.       (list XlsPat "Excel8.olb" MSOVer)
  20.     )
  21.   )
  22. )
  23.  
Comando: (MsX_TypeLib2)
("C:\\Program Files\\Microsoft Office 15\\Root\\Office15\\" "Excel.exe" "15")

AutoCAD 2013 > Comando: (vlax-get-or-create-object "Excel.Application")
nil
error: see image

BricsCAD V15 > : (vlax-get-or-create-object "Excel.Application")
#<VLA-OBJECT _Application 000000001E1AC358>
no error
Comments?

kpblc

  • Bull Frog
  • Posts: 396
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #1 on: May 23, 2015, 01:41:30 AM »
What do you want to do with Excel? Why don't use something like
(vlax-get-or-create-object "Microsoft.Excel")
???
Sorry for my English.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #2 on: May 23, 2015, 03:11:23 AM »
What do you want to do with Excel?
I am using  functions that I use for many years such:
Code - Auto/Visual Lisp: [Select]
  1. ; Function   : MsX_OpenNew
  2. ; Description: Opens a new WorkBooks of Excel 97, 2000, XP or >=2003
  3. ; Arguments  : display-mode > T = SHOW - nil = HIDE
  4. ; Example    : (MsX_LoadTypeLib) (MsX_OpenNew T)
  5. ;
  6. (defun MsX_OpenNew (DspMod)
  7.   (princ "\nCreating new Excel Spreadsheet file...")
  8.   (cond
  9.     ( (setq *ExclApp*  (vlax-get-or-create-object "Excel.Application"))
  10.       (setq
  11.         *XlAcWbk* (msxm-Add (vlax-get-property *ExclApp* 'WorkBooks))
  12.         *XlAcSht* (msxp-get-ActiveSheet *ExclApp*)
  13.         *XlAcCls* (msxp-get-Cells       *XlAcSht*)
  14.       )
  15.       (if DspMod (vla-put-visible *ExclApp* 1) (vla-put-visible *ExclApp* 0))
  16.     )
  17.     ( (alert "ERROR\n\nCannot initialize Excel.Application") )
  18.   )
  19. )
  20. (defun msxp-get-ActiveSheet        (ExlObj) (vlax-get-property  ExlObj 'ActiveSheet             ))
  21. (defun msxp-get-Cells              (ShtObj) (vlax-get-property  ShtObj 'Cells                   ))
  22. (defun msxm-Add                    (VlaObj) (vlax-invoke-method VlaObj 'Add                     ))
Why don't use something like (vlax-get-or-create-object "Microsoft.Excel") ???
I get a nil:Comando: (vlax-get-or-create-object "Microsoft.Excel")
nil

Now I get a new error from Office who fails to verify the license, see image (in this new Laptop I have "Office Home & Business 2013", just bought):

Code: [Select]
Comando: (setq *ExclApp*  (vlax-get-or-create-object "Excel.Application"))
#<VLA-OBJECT _Application 00000000253cd3d8>

Comando: (setq *XlAcWbk* (msxm-Add (vlax-get-property *ExclApp* 'WorkBooks)))
; errore: Il server ActiveX ha restituito un errore: La chiamata di procedura remota non è riuscita

Comando: (setq *XlAcWbk* (msxm-Add (vlax-get-property *ExclApp* 'WorkBooks)))
; errore: Il server ActiveX ha restituito un errore: Server RPC non disponibile

Comando: (setq *ExclApp*  (vlax-get-or-create-object "Excel.Application"))
#<VLA-OBJECT _Application 00000000253caf68>

Comando: (setq *XlAcWbk* (msxm-Add (vlax-get-property *ExclApp* 'WorkBooks)))
; errore: Il server ActiveX ha restituito un errore: La chiamata di procedura remota non è riuscita
:tickedoff:
no problems with Bricscad... :-)

kpblc

  • Bull Frog
  • Posts: 396
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #3 on: May 24, 2015, 02:30:14 PM »
First of all, sorry for my previous post: i wrote it inder Linux OS.
Secondary - when you're start Excel manually, will it work correctly?
Thirdly: try do not use eraly connection. Test code on lately connection (i mean no tlb-import). Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun test (/ xls_app xls_workbooks xls_workbook xls_sheets)
  2.   (if (= (type (setq xls_app (vl-catch-all-apply
  3.                                (function
  4.                                  (lambda ()
  5.                                    (vlax-get-or-create-object "Excel.Application")
  6.                                    ) ;_ end of lambda
  7.                                  ) ;_ end of function
  8.                                ) ;_ end of vl-catch-all-apply
  9.                      ) ;_ end of setq
  10.                ) ;_ end of type
  11.          'vla-object
  12.          ) ;_ end of =
  13.     (progn
  14.       (vlax-put-property xls_app 'visible :vlax-true)
  15.       (setq xls_workbooks (vlax-get-property xls_app 'workbooks)
  16.             xls_workbook  (vlax-invoke-method xls_workbooks 'add)
  17.             xls_sheets    (vlax-get-property xls_workbook 'sheets)
  18.             xls_sheet     (vlax-get-property xls_sheets 'item 1)
  19.             ) ;_ end of setq
  20.       ) ;_ end of progn
  21.     (alert "Can't create Excel Application object!")
  22.     ) ;_ end of if
  23.   (foreach item (list xls_sheet xls_sheets xls_workbook xls_workbooks xls_app)
  24.     (vl-catch-all-apply
  25.       (function
  26.         (lambda ()
  27.           (vlax-release-object item)
  28.           ) ;_ end of lambda
  29.         ) ;_ end of function
  30.       ) ;_ end of vl-catch-all-apply
  31.     (setq item nil)
  32.     ) ;_ end of foreach
  33.   ) ;_ end of defun
Sorry for my English.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #4 on: May 25, 2015, 03:18:33 AM »
First of all, sorry for my previous post: i wrote it inder Linux OS.
  :-)   Thanks for asnwer!  :-)
Quote
Secondary - when you're start Excel manually, will it work correctly?
Yes.
Quote
Thirdly: try do not use eraly connection.
can you be more specific?
Quote
Test code on lately connection (i mean no tlb-import). Something like this:
I have tested but I get the same result:
"Microsoft Office is unable to verify the license for this product. Restore the application from the Control Panel." See previous 2013b image.
This is a brand new Laptop W8.1-Office 2013 H&B-Acad2013, in previous PC same programs all is OK (one difference: Windows 8.1 updated from 8  ).
Maybe is a antivirus (kaspersky) problem? Just a curiosity: now also I can not drag&drop a Lisp file in the AutoCAD windows to load...
With Bricscad all is OK!   :thinking:

kpblc

  • Bull Frog
  • Posts: 396
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #5 on: May 25, 2015, 03:29:05 AM »
I'm using DrWeb (I don't like KAV - you can say it's my religion ;)).
If you're insert at dwg file an Excel sheet as OLE-object, save and reopen file - will Excel starts after double-click on OLE object? If it doesn't, try to check KAV settings.
Sorry for my English.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #6 on: May 25, 2015, 08:42:58 AM »
I'm using DrWeb (I don't like KAV - you can say it's my religion ;)).
If you're insert at dwg file an Excel sheet as OLE-object, save and reopen file - will Excel starts after double-click on OLE object? If it doesn't, try to check KAV settings.
I have disabled KAV but I have the same problem... tested with _INSERTOBJ but I get the same result:
"Microsoft Office is unable to verify the license for this product. Restore the application from the Control Panel." See previous 2013b image.    :rolleyes2:

kpblc

  • Bull Frog
  • Posts: 396
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #7 on: May 25, 2015, 08:46:55 AM »
I hope you tested it manually ))
I afraid OLE-mechanism crashed (will it works when you're insert Excel sheet to MS Word file?). Unfotunally I don't know how to repair it :( Sorry.
Sorry for my English.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #8 on: May 25, 2015, 09:10:14 AM »
>> will it works when you're insert Excel sheet to MS Word file?.
Yes all is OK. Thanks again.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #9 on: May 26, 2015, 01:12:26 PM »
I tried to install VBA Enabler and activate some Library (see image), but without success...  :tickedoff:
Is there somebody who uses Office 2013?            :?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Excel.Application error on AutoCAD/Excel 2013
« Reply #10 on: June 03, 2015, 04:33:19 PM »
Tested on AutoCAD 2016 (vanilla) all ok, _INSERTOBJ ok, (vlax-get-or-create-object "Excel.Application") ok, etc...

So, Autocad 2013 (I have Mechanical SP2) it is not full compatible with Office 2013...   :knuppel2: