TheSwamp

Code Red => VB(A) => Topic started by: MSTG007 on October 13, 2015, 09:32:31 AM

Title: Excel Cell Value to Command Line
Post by: MSTG007 on October 13, 2015, 09:32:31 AM
I was wondering if there is a certain VBA Script that I can select a Cell and have the Cell Value you transferred to the Active AutoCAD Command line.
Title: Re: Excel Cell Value to Command Line
Post by: David Hall on October 14, 2015, 10:27:19 AM
i would think that it could be done fairly easily, let me see if I have some code that will do it easily
Title: Re: Excel Cell Value to Command Line
Post by: MSTG007 on October 14, 2015, 11:27:19 AM
That would be sweet!
Title: Re: Excel Cell Value to Command Line
Post by: David Hall on October 15, 2015, 08:24:07 AM
this post http://www.theswamp.org/index.php?topic=21962.msg265072#msg265072 (http://www.theswamp.org/index.php?topic=21962.msg265072#msg265072) should get you all the code you need to connect, open a spreadsheet, and search for a row/column.  from there you should be able to read the cell and send it back to autocad, probably using the dreaded send command.
Title: Re: Excel Cell Value to Command Line
Post by: RICVBA on October 17, 2015, 01:26:01 AM
an alternative approach could be using Excel as the server applicaton controlling Autocad
in that case the following could be of any help

1) insert an event handler for selection changes in your sheet module
2) have it send the selected cell value to Autocad command line via the "prompt" method of the "Utility" object

something like this
Code: [Select]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then ThisDrawing.Utility.prompt Target.value
End Sub