<?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: VBA basics - How to read excel cells value? in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441561#M16224</link>
    <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Attached is a tutorial that I got from somewhere. I &lt;BR /&gt;
think it was AUGI but not sure. It deals with Autocad VBA to Excel. &lt;BR /&gt;
&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;This is the code I used to create Dtext in &lt;BR /&gt;
Autocad.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;lt;code&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;If obRoofOver6in.Value = True &lt;BR /&gt;
Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim textObj As &lt;BR /&gt;
AcadText&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim TextString As &lt;BR /&gt;
String&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim instPT(0 To 2) As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim height As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextString = &lt;BR /&gt;
Label31.Caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instPT(0) = 2138: instPT(1) = 242.1: &lt;BR /&gt;
instPT(2) = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height = 4&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
Set textObj = ThisDrawing.ModelSpace.AddText(TextString, instPT, &lt;BR /&gt;
height)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.Layer = &lt;BR /&gt;
"SL_NTS"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.color = &lt;BR /&gt;
92&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.StyleName = "DIN"&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;lt;/code&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 04 Mar 2009 22:18:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-03-04T22:18:32Z</dc:date>
    <item>
      <title>VBA basics - How to read excel cells value?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441560#M16223</link>
      <description>Hi,&lt;BR /&gt;
I just started using VBA in AutoCAD. I need to do this:&lt;BR /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;
1. I got an opened excel worksheet named "TEST", from AutoCAD VBA I need to read cell B1 value and export this value to string.&lt;BR /&gt;
2. Save the string as a text on the drawing.&lt;BR /&gt;
3. Read B2 value export to string and save as text on the drawing.&lt;BR /&gt;
and so on till B8&lt;BR /&gt;
sounds easy?but not for me&lt;BR /&gt;
Could anyone help me with this plz&lt;BR /&gt;
thx</description>
      <pubDate>Wed, 04 Mar 2009 11:30:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441560#M16223</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-04T11:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: VBA basics - How to read excel cells value?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441561#M16224</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Attached is a tutorial that I got from somewhere. I &lt;BR /&gt;
think it was AUGI but not sure. It deals with Autocad VBA to Excel. &lt;BR /&gt;
&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;This is the code I used to create Dtext in &lt;BR /&gt;
Autocad.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;lt;code&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;If obRoofOver6in.Value = True &lt;BR /&gt;
Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim textObj As &lt;BR /&gt;
AcadText&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim TextString As &lt;BR /&gt;
String&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim instPT(0 To 2) As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim height As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextString = &lt;BR /&gt;
Label31.Caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instPT(0) = 2138: instPT(1) = 242.1: &lt;BR /&gt;
instPT(2) = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height = 4&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
Set textObj = ThisDrawing.ModelSpace.AddText(TextString, instPT, &lt;BR /&gt;
height)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.Layer = &lt;BR /&gt;
"SL_NTS"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.color = &lt;BR /&gt;
92&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textObj.StyleName = "DIN"&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;lt;/code&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 Mar 2009 22:18:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441561#M16224</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-04T22:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: VBA basics - How to read excel cells value?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441562#M16225</link>
      <description>Here is a little routine you can try.  It is no the best sample or a tutorial, but something simple to get you thinking.  Create an Excel file and save it as "C:\My Documents\TestBook.xls", name the first WorkSheet "Test" and write something in cells B1:B8.  Open AutoCAD create a new VBA project and write the following code in a code module or ThisDrawing object.  Create a new drawing with the imperial template.  Finally, run the routine. One more thing forgot, you also need to add reference to your excel application to the VBA project.&lt;BR /&gt;
&lt;BR /&gt;
{code}Public Sub GetExcelInfo()&lt;BR /&gt;
Dim exapp As Excel.Application&lt;BR /&gt;
Dim wsheet As Excel.Worksheet&lt;BR /&gt;
Dim cll As Excel.Range&lt;BR /&gt;
Dim rg As Excel.Range&lt;BR /&gt;
Dim pt(2) As Double&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Set exapp = CreateObject("Excel.Application")&lt;BR /&gt;
&lt;BR /&gt;
exapp.Visible = True&lt;BR /&gt;
&lt;BR /&gt;
exapp.Workbooks.Open ("C:\My Documents\TestBook.xls")&lt;BR /&gt;
&lt;BR /&gt;
Set wsheet = exapp.ActiveSheet&lt;BR /&gt;
&lt;BR /&gt;
If wsheet.Name = "Test" Then&lt;BR /&gt;
&lt;BR /&gt;
    Set rg = wsheet.Range(Cells(1, 2), Cells(8, 2))&lt;BR /&gt;
    &lt;BR /&gt;
    rg.Select&lt;BR /&gt;
    &lt;BR /&gt;
    &lt;BR /&gt;
    pt(0) = 0: pt(1) = 0: pt(2) = 0&lt;BR /&gt;
    &lt;BR /&gt;
    For Each cll In rg&lt;BR /&gt;
        ThisDrawing.ModelSpace.AddText cll.Value, pt, 0.16&lt;BR /&gt;
        pt(0) = pt(0) + 1&lt;BR /&gt;
        pt(1) = pt(1) + 1&lt;BR /&gt;
    Next cll&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
If Not exapp Is Nothing Then&lt;BR /&gt;
    exapp.Quit&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.Regen (acActiveViewport)&lt;BR /&gt;
&lt;BR /&gt;
End Sub{code}&lt;BR /&gt;
&lt;BR /&gt;
Edited by: HJohn1 on Mar 4, 2009 10:57 PM

Edited by: HJohn1 on Mar 5, 2009 1:47 AM</description>
      <pubDate>Wed, 04 Mar 2009 22:56:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-basics-how-to-read-excel-cells-value/m-p/2441562#M16225</guid>
      <dc:creator>HJohn1</dc:creator>
      <dc:date>2009-03-04T22:56:46Z</dc:date>
    </item>
  </channel>
</rss>

