<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to import lookup table value from excel cell in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11655818#M39330</link>
    <description>&lt;P&gt;You have a couple of separate&amp;nbsp; posts now and Gile and I have been responding to you, the get, put Acad &amp;lt;--&amp;gt; Excel programming requires that you have a bit of experience when coding in lisp, it is not rocket science, but once you get the hang it can be very simple. The hardest bit is to do with is excel open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to take a step back and study the functions that are in the code being provided. Get to understand how to convert say a A3 to 1 3 for get put, and the opposite 1 3 to A3. Here are 2 programs Getxecel.lsp is where I started and then wrote my own version with some extra features.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to understand how to do stuff like&amp;nbsp;(defun putcell (cellname val1 / ) but cellname starts as row and column&amp;nbsp;&lt;/P&gt;&lt;P&gt;values in Acad. So have to use an extra function to do the conversion then pass the value. That is code by Gile.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A minimum bit of code open excel and have a blank worksheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:testexcel ( / )
(defun putcell (cellname val1 / )
(setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
(vlax-put-property myRange 'Value2 val1)
)

(setq myxl (vlax-get-object "Excel.Application"))
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(putcell "A3" "123")
(putcell "B3" "456")
(putcell "C3" "789")
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2023 05:12:01 GMT</pubDate>
    <dc:creator>Sea-Haven</dc:creator>
    <dc:date>2023-01-04T05:12:01Z</dc:date>
    <item>
      <title>How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11503283#M39322</link>
      <description>&lt;P&gt;hello forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a task to import a value from excel cell to an lookup table value named as "Tag1" which to be changed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have placed a sample code below. I am not sure how to do the process. Please make changes in the below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq cell (vlax-variant-value (vlax-get-property rng 'Item (vlax-get-property xlCell "Row") (+ 6 (vlax-get-property xlCell "Column")) ) ) ) (vl-some '(lambda (x) (if (= (vlax-get x 'tagstring) "Tag1") (vla-put-textstring x (RTOS (vlax-variant-value (vlax-get-value cell 'value2)) 2 2 )))) (vlax-invoke obj (get-properties "Tag1" BlockRefObj)))&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 06:51:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11503283#M39322</guid>
      <dc:creator>vijay.shankar3BXDM</dc:creator>
      <dc:date>2022-10-24T06:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11503411#M39323</link>
      <description>&lt;P&gt;That is about a 1/3 of what you need, you must open a link with excel 1st, you can then simply&amp;nbsp; GETCELL with a known cell address like "A6"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you looked at getexcel.lsp a good starting point.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When asking this type of questions need the following to be posted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 dwg before&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 dwg after&lt;/P&gt;&lt;P&gt;3 excel file&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 08:10:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11503411#M39323</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2022-10-24T08:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11509105#M39324</link>
      <description>&lt;P&gt;Dear Sea,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I was actually placed a bit of code and requested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am placing the before and after file and the excel file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please have a review. let me know how to apply the lookup value(Lookup1) in the drawwing from excel.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:00:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11509105#M39324</guid>
      <dc:creator>vijay.shankar3BXDM</dc:creator>
      <dc:date>2022-10-26T09:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11511584#M39325</link>
      <description>&lt;P&gt;So you just want 2 layouts per column A, matching the number in column B, one match top number, one match bottom number.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 03:31:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11511584#M39325</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2022-10-27T03:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653625#M39326</link>
      <description>&lt;P&gt;Yes, Could you please provide the lisp code for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I need the lookup value to be updated as per column2 based on the value in the first column which is layout number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see the samples attached.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 08:31:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653625#M39326</guid>
      <dc:creator>vijay.shankar3BXDM</dc:creator>
      <dc:date>2023-01-03T08:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653687#M39327</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;To read/write in an Excel sheet, you can use (or get inspiration from) the code of &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-data-to-excel/m-p/11628449/highlight/true#M440837" target="_blank" rel="noopener"&gt;this reply&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 09:12:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653687#M39327</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-01-03T09:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653715#M39328</link>
      <description>&lt;P&gt;Hi this is not suitable for my task. as i need to import to an particular attribute in the excel. You just send me the simple export and import. It won't work.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 09:28:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653715#M39328</guid>
      <dc:creator>vijay.shankar3BXDM</dc:creator>
      <dc:date>2023-01-03T09:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653739#M39329</link>
      <description>&lt;P&gt;This suits the "read Excel" part of your task. You just have to populate the attributes of each Layout block references with the got data. You'll find many examples on how to set attribute values in this forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 09:51:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11653739#M39329</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-01-03T09:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11655818#M39330</link>
      <description>&lt;P&gt;You have a couple of separate&amp;nbsp; posts now and Gile and I have been responding to you, the get, put Acad &amp;lt;--&amp;gt; Excel programming requires that you have a bit of experience when coding in lisp, it is not rocket science, but once you get the hang it can be very simple. The hardest bit is to do with is excel open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to take a step back and study the functions that are in the code being provided. Get to understand how to convert say a A3 to 1 3 for get put, and the opposite 1 3 to A3. Here are 2 programs Getxecel.lsp is where I started and then wrote my own version with some extra features.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to understand how to do stuff like&amp;nbsp;(defun putcell (cellname val1 / ) but cellname starts as row and column&amp;nbsp;&lt;/P&gt;&lt;P&gt;values in Acad. So have to use an extra function to do the conversion then pass the value. That is code by Gile.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A minimum bit of code open excel and have a blank worksheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:testexcel ( / )
(defun putcell (cellname val1 / )
(setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
(vlax-put-property myRange 'Value2 val1)
)

(setq myxl (vlax-get-object "Excel.Application"))
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(putcell "A3" "123")
(putcell "B3" "456")
(putcell "C3" "789")
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 05:12:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11655818#M39330</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-01-04T05:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11656421#M39331</link>
      <description>&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;(defun c:QQQQQTEXTFINDly (/ CELL CELL1 EXCDATA FILENAME I ICOL IROW IROWS LW-LST MAKE_LW NUMBER NUMBERSTR NUMBERSTR1 OBJ OBJ2 RNG SSVP1 SSVP22 VP1 VP2 XLAPP XLBOOK XLCELL XLFRANGE XLRANGE XLRANGEC XLSHEET)
  (vl-load-com)
  
  
  (if (setq fileName (getfiled "Select Excel file to find cell address :" (getvar "dwgprefix") "xlsx;xls" 16))
    (progn
      
      
      
      (setq xlApp (vlax-create-object "Excel.Application"))
      (vlax-put-property xlApp "Visible" :vlax-true)
      (setq xlBook (vlax-invoke-method (vlax-get-property xlApp 'WorkBooks) "Open" fileName ) )
      (vlax-invoke-method xlBook "Activate")
      (setq xlSheet (vlax-get-property (vlax-get-property xlBook "WorkSheets") "Item" 1) )
      
      (setq xlRangeC (vlax-invoke-method xlSheet "Activate") )
      (setq xlRange (vlax-get-property xlSheet "Range" "a2:b10"))
      (vlax-invoke-method xlRange "Select")
      (setq iCol (vlax-get-property xlRange "Column"))
      (setq iRows (vlax-get-property(vlax-get-property xlRange "Rows") "Count" )iRow  (vlax-get-property xlRange "Row") )
      (setq rng (vlax-get-property xlApp 'Cells))
      
      (setq
	ExcData	 (vlax-safearray-&amp;gt;list
		   (vlax-variant-value
		     (vlax-get-property xlRange 'Value)
		     )
		   )
	)
      
      (setq
	ExcData (mapcar
		  (function (lambda (x)  (mapcar 'vlax-variant-value x) ))
		  ExcData
		  )
	)
      
      
      ;(setq lw-lst nil)
      (foreach pt ExcData
	(setq lw-lst (append (list(car pt)) lw-lst))
	
	)
      
   
      (setq make_lw (reverse (vl-remove nil lw-lst)))
      
      
      
      ;;Group-1.1
      (setq i 0)


      
      (repeat (length make_lw)


	
	(setq numberstr (strcat "Group-"  (RTOS (setq number (nth i make_lw)) 2 0 )".1" ))
	(vl-cmdf "._layout" "c" "00" numberstr)   
	(vl-cmdf "._layout" "s" numberstr "._pspace")
	(setvar "ctab" numberstr)
	

	(setq ssvp1 (ssget "x" (list (cons 0 "insert") (cons 410 numberstr) )))
	(setq vp1 (ssname ssvp1 0))
	(setq obj (vlax-ename-&amp;gt;vla-object (ssname ssvp1 0)))

	(setq xlCell (vlax-invoke-method
		       xlRange
		       "Find"
		       (vlax-make-variant number)
		       xlFRange
		       -4163
		       1
		       1
		       1
		       nil
		       nil
		       )
	      )
	
	
	(setq cell (vlax-variant-value (vlax-get-property rng 'Item (vlax-get-property xlCell "Row") (vlax-get-property xlCell "Column")    )     )  )
	(vl-some '(lambda (x) (if (= (vlax-get x 'tagstring) "HeadNumber") (vla-put-textstring x (RTOS (vlax-variant-value  (vlax-get-property cell 'value2)) 2 2 )))) (vlax-invoke obj 'getattributes))


	
	(setq cell1 (vlax-variant-value (vlax-get-property rng 'Item (vlax-get-property xlCell "Row") (+ 1  (vlax-get-property xlCell "Column")  )    )     )  )




	(vl-some '(lambda (x) (if (= (vla-get-PropertyName x) "Lookup1") (vlax-put x 'Value (RTOS (vlax-variant-value  (vlax-get-property cell1 'value2)) 2 2 )))) (vlax-invoke obj 'GetDynamicBlockProperties))
	
	
	
	
	
	(setq numberstr1 (strcat "Group-"  (RTOS (setq number (nth i make_lw)) 2 0 )".2" ))
	(vl-cmdf "._layout" "c" "00" numberstr1)
	
	(setvar "ctab" numberstr1)
	
	(setq ssvp22 (ssget "x" (list (cons 0 "insert") (cons 410 numberstr1) )))
	(setq vp2 (ssname ssvp22 0))
	(setq obj2 (vlax-ename-&amp;gt;vla-object (ssname ssvp22 0)))

	


	(vl-some '(lambda (x) (if (= (vla-get-PropertyName x) "Lookup1") (vlax-put x 'Value (RTOS (+ 1 (- 10 (vlax-variant-value  (vlax-get-property cell1 'value2)) ) ) 2 2 )))) (vlax-invoke obj2 'GetDynamicBlockProperties))
	
	
	
	(setq i (1+ i))




	
	)
      
      )
    )

  
  (princ)
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="12m.gif" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1158580i6489D20E23DC503B/image-size/large?v=v2&amp;amp;px=999" role="button" title="12m.gif" alt="12m.gif" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 11:45:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11656421#M39331</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-01-04T11:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to import lookup table value from excel cell</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11658977#M39332</link>
      <description>&lt;P&gt;Not sure how that helps to learn about acad &amp;lt;--&amp;gt; Excel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;look at this get excel range by FIXO.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; thanks to Lee-mac for this defun 
; www.lee-mac.com
; 44 is comma 9 is tab 34 is space 58 is colon
(defun _csv-&amp;gt;lst58 ( str / pos )
	(if (setq pos (vl-string-position 58 str))
		(cons (substr str 1 pos) (_csv-&amp;gt;lst58 (substr str (+ pos 2))))
		(list str)
    )
)

; great get range by FIXO

(defun getrangexl2 ( / lst UR CR RADD )
(vl-catch-all-error-p
	   (setq Rng
		  (vl-catch-all-apply
		    (function (lambda ()
				(vlax-variant-value
				  (vlax-invoke-method
				    (vlax-get-property myxl 'Application)
				    'Inputbox
				    "Select a Range: "
				    "Range Selection "
				    nil
				    nil
				    nil
				    nil
				    nil
				    8))))))
)
(setq xrng (vlax-get-property rng "address"))
(setq xxrng xrng)
(repeat 4 (setq xxrng(vl-string-subst "" "$" xxrng)))
(setq xxxrng (_csv-&amp;gt;lst58 xxrng))
(setq rngst (columnrow (nth 0 xxxrng)) rngend (columnrow (nth 1 xxxrng)))
(setq *ExcelData@ nil )
(setq Row# (nth 1 rngst))
(repeat (+ (- (nth 1 rngend)(nth 1 rngst) ) 1)
(setq Data@ nil)
(setq Column# (nth 0 rngst))
(repeat (+  (- (nth  0 rngend)(nth 0 rngst) ) 1)
(setq Range$ (strcat (Number2Alpha Column#)(itoa Row#)))
(setq ExcelRange (vlax-get-property myxl "Range" range$))
(setq ExcelVariant (vlax-get-property ExcelRange 'Value))
(setq ExcelValue (vlax-variant-value ExcelVariant))
(setq Data@ (append Data@ (list ExcelValue)))
(setq Column# (1+ Column#))
)
(setq *ExcelData@ (append *ExcelData@ (list Data@)))
(setq Row# (1+ Row#))
)
(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 Jan 2023 12:16:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-import-lookup-table-value-from-excel-cell/m-p/11658977#M39332</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-01-05T12:16:33Z</dc:date>
    </item>
  </channel>
</rss>

