excel cell placement by cursor

J

john coon

I'm trying to get the x's and y's autocad coordinate locations placed into a
open excel sheet by having the user pick the start cell by cursor. can I do
that?

sample would look like this where the row number is set by some focus by the
users.
row1cell1 row1cell2 row1cell3 row1cell4
x1,y1 to x2,y2 distance

I guess I need to check if excel is running if it is then select the cursor
location if not then message open summary excel file. next issue is how do I
from excel flip back to autocad to get the next two points to be located and
have excel jump to start row - 1

Any comments or direction are welcome
Thanks
John Coon

'excel ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Option Explicit

Public intRow As Integer
Public strCell As String

' Application - Excel
Public oExcel As Excel.Application
Public oBook As Excel.Workbook
Public oSheet As Excel.Worksheet
'or I need to just connect to the already open file
Private Sub CreateExcel()
Dim i As Integer
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

oExcel.Visible = True
End Sub
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Sub insertpoints()
Dim varDataPnt1 As Variant
Dim dblnorthing As Double
Dim dbleasting As Double
Dim dbldir As Double
Dim pi As Double
pi = 3.14159265358979

Dim dblRot As Double
dblRot = -ThisDrawing.GetVariable("VIEWTWIST")
Dim dblRot180 As Double

dblRot180 = (dblRot + pi)

'this is the screen pick point
varDataPnt1 = ThisDrawing.Utility.GetPoint(, "Select first point: ")

Dim insertionPnt1(0 To 2) As Double
insertionPnt1(0) = varDataPnt1(0) 'x
insertionPnt1(1) = varDataPnt1(1) 'y
varDataPnt1(2) = 0 'z

MsgBox "The Northing Easting Point Location:" & vbCrLf & _
" Northing: " & varDataPnt1(1) & vbCrLf & _
" Easting: " & varDataPnt1(0) & vbCrLf & vbCrLf & _
" Direction: " & dbldir, vbInformation, "Left R/W End Coordinate
Data"
Dim pt1 As Variant
pt1 = varDataPnt1 ' x,y,z, of pick point


Dim varDataPnt2 As Variant
'this is the screen pick point
varDataPnt2 = ThisDrawing.Utility.GetPoint(, "Select Second point: ")
Dim insertionPnt2(0 To 2) As Double
insertionPnt2(0) = varDataPnt2(0) 'x
insertionPnt2(1) = varDataPnt2(1) 'y
varDataPnt2(2) = 0 'z

MsgBox "The Northing Easting Point Location:" & vbCrLf & _
" Northing: " & varDataPnt2(1) & vbCrLf & _
" Easting: " & varDataPnt2(0) & vbCrLf & vbCrLf & _
" Direction: " & dbldir, vbInformation, "Right R/W End Coordinate
Data"
Dim pt2 As Variant
pt2 = varDataPnt2 ' x,y,z, of pick point

'length calc from pick points
Dim x, y, dist As Double
x = varDataPnt1(0) - varDataPnt2(0)
y = varDataPnt1(1) - varDataPnt2(1)
dist = Sqr(x ^ 2 + y ^ 2)


Dim distformat As String
distformat = "#0.00"
Dim pointdist As String
pointdist = Format(dist, distformat)

MsgBox "Distance Between PT1 and PT2 = " & pointdist

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top