Author Topic: error bad argument type vla-object  (Read 3772 times)

0 Members and 1 Guest are viewing this topic.

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
error bad argument type vla-object
« on: January 31, 2013, 10:41:19 AM »
I have the following error when I try to run the following lisp.
Please help...
thank you...
__________________________________________________________________________________________

Code - Auto/Visual Lisp: [Select]
  1. ;; local defun
  2. (defun RefSelection (/ *error* Excelapp Sel Sht Rng vl Wbk)
  3.   (defun *error*  (msg)
  4.     (if
  5.       (vl-position
  6.         msg
  7.         '("console break"
  8.           "Function cancelled"
  9.           "quit / exit abort"
  10.           )
  11.         )
  12.        (princ "Error!")
  13.        (princ msg)
  14.        )
  15.             (vl-catch-all-apply
  16.         'vlax-invoke-method
  17.         (list Wbk "Close")
  18.       )
  19.  
  20.         (vl-catch-all-apply
  21.           'vlax-invoke-method
  22.           (list ExcelApp "Quit")
  23.         )
  24.  
  25.   (mapcar
  26.     (function (lambda (x)(vl-catch-all-apply(function (lambda()
  27.                 (if (not (vlax-object-released-p x))
  28.                   (progn
  29.                   (vlax-release-object x)
  30.                   (setq x nil))
  31.                 )
  32.               )
  33.     )
  34.                            )
  35.                 )
  36.               )
  37.     (list Sel Sht Wbk ExcelApp)
  38.   )  
  39.   (gc)
  40.   (gc)
  41.     (princ)
  42.     )
  43.  
  44.  
  45. (setq ExcelApp (vl-catch-all-apply
  46.                (function (lambda ()(vlax-get-or-create-object "Excel.Application")))))
  47.  
  48.       (setq Wbk
  49.              (vl-catch-all-apply
  50.                (function (lambda ()
  51.                            (vlax-get-property ExcelApp "ActiveWorkBook"))))))
  52.   (progn
  53.     (alert "Excel WorkBook Must Be Open Before!")
  54.     (exit)
  55.     (*error* nil)
  56.     (princ)
  57.     )
  58.   )
  59. (setq Sht
  60.        (vl-catch-all-apply
  61.          (function (lambda ()
  62.                      (vlax-get-property ExcelApp "ActiveSheet")))))
  63.  
  64. (vlax-put-property ExcelApp 'visible :vlax-true)
  65.  
  66. (vlax-put-property ExcelApp 'ScreenUpdating :vlax-true)
  67.  
  68. (vlax-put-property ExcelApp 'DisplayAlerts :vlax-false)
  69.  
  70.            (setq Rng
  71.                   (vl-catch-all-apply
  72.                     (function (lambda ()
  73.                                 (vlax-variant-value
  74.                                   (vlax-invoke-method
  75.                                     (vlax-get-property Wbk 'Application)
  76.                                     'Inputbox
  77.                                     "Select a single cell with mouse to be bolded."
  78.                                     "Range Selection"
  79.                                     nil
  80.                                     nil
  81.                                     nil
  82.                                     nil
  83.                                     nil
  84.                                     8))))))))
  85.   (progn
  86.     (vlax-put-property ExcelApp 'DisplayAlerts :vlax-true)
  87.  
  88.  
  89.     (vlax-invoke Rng 'Select)
  90.     )
  91.   )
  92.  
  93. (if Rng
  94.  
  95.   (setq vl  (vlax-variant-value
  96.                          (vlax-get-property Rng 'value)))
  97.  (setq vl nil))
  98.  
  99. (*error* nil)
  100.  
  101.   vl
  102. )
  103.  
  104.  
  105. (defun C:Xss (/ ahha)
  106.  
  107. (setq ahha (RefSelection))
  108.   (alert (strcat "Your block name is: " ahha))
  109.  
  110.   ;; ---    rest your code to insert block here  ---  :
  111.  
  112.  
  113. )
  114. (princ "\nType Xss in the command line")
« Last Edit: February 04, 2013, 11:37:26 AM by CAB »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: error bad argument type vla-object
« Reply #1 on: January 31, 2013, 10:56:45 AM »
What are you trying to accomplish? From a quick check ...
WBK does not get set .. in turn bombs the rest of the code
Code: [Select]
(setq wbk (vl-catch-all-apply
    (function (lambda () (vlax-get-property excelapp "ActiveWorkBook")))
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: error bad argument type vla-object
« Reply #2 on: January 31, 2013, 11:30:43 AM »
Hi Gator,
what we are trying to accomplish, is to update info from a workbook or spreadsheet that is linked to our drawing template by selecting the informatin from that workbook using the mouse insted of linking info manually.
E.g. drawing numbers changes as we created a new drawing, then the user must go to the Datalink within Autocad and poinitng to the right cell within the workbook.

does this makes sense?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: error bad argument type vla-object
« Reply #3 on: January 31, 2013, 11:49:18 AM »
It does make sense but I do not have the time to help you right now .... real work beckons  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: error bad argument type vla-object
« Reply #4 on: January 31, 2013, 12:28:41 PM »
Thank you Gator,
If you ever have the chance to help us out, please we will appreciate it...

thank you...