'DistanceCalc.bas calculates the distance between the first (now LAST) ' two points in the Surfer digit.bln window. - TB - 29 Apr 04. 'Changed SendKeys to get the LAST two points in the digit.bln window. ' TB - 20 Sep 04. Sub Main Debug.Print "----- ";Time;" -----" On Error GoTo err1 Set surf = GetObject(,"surfer.application") On Error GoTo 0 On Error GoTo err2 AppActivate "digit.bln" On Error GoTo 0 SendKeys "^{end}{up}{end}+{home}+{up}^c^{end}" Wait .1 AppActivate "DistanceCalc" text1 = Clipboard 'For i = 1 To Len(text1) ' Debug.Print Mid(text1,i,1);" "; 'Next i points1 = Split(text1,Chr(10)) 'For i = 0 To UBound(points1) ' Debug.Print i;": ";points1(i) 'Next i x1 = Val(Split(points1(0),",")(0)) y1 = Val(Split(points1(0),",")(1)) x2 = Val(Split(points1(1),",")(0)) Debug.Print x1;" ";y1;" ";x2 y2 = Val(Split(points1(1),",")(1)) 'x1 = Val(Left(points1(0),InStr(points1(0),",")-1)) 'y1 = Val(Mid(points1(0),InStr(points1(0),",")+2)) 'x2 = Val(Left(points1(1),InStr(points1(1),",")-1)) 'y2 = Val(Mid(points1(1),InStr(points1(1),",")+2)) dist = Sqr(Power(x2-x1,2) + Power(y2-y1,2)) Debug.Print "Distance: ";dist Debug.Print " (";x1;",";y1;")" Debug.Print " (";x2;",";y2;")" MsgBox("Distance: "+dist+vbCrLf+ _ " ("+x1+","+y1+")"+vbCrLf+ _ " ("+x2+","+y2+")","Distance") End err1: MsgBox("Start Surfer, right-click on map, digitize two points, "+ vbCrLf + _ "digitize two points, and run DistanceCalc.bas in Scripter.", _ ,"Can Not Find Surfer") End err2: MsgBox("Digitize digit.bln "+Err.Description+vbCrLf+vbCrLf+ _ "Start Surfer,"+vbCrLf+ _ "right-click on a map," + vbCrLf + _ "digitize two points,"+ vbCrLf + _ "and run DistanceCalc.bas in Scripter.") End End Sub Function Power(X,Y) P = 1 For I = 1 To Y P = P*X Next I Power = P End Function