|
我是一个VBA入门者,请问在VBA中引用EXCEL 对象后如何弹出EXCEL保存对话框?
Sub PgDxx()
Dim Excel As Excel.Application
Dim ExcelSheet As Object
Dim ExcelWorkbook As Object
Dim RowNum As Integer
Dim HeadTF As Boolean
Dim Elem As AcadEntity
Dim Array1 As Variant
Dim Count As Integer
Set Excel = New Excel.Application
Set ExcelWorkbook = Excel.Workbooks.Add
Set ExcelSheet = Excel.ActiveSheet
ExcelWorkbook.SaveAs "d:\dwgdata.xls"
ExcelSheet.Cells(1, 1).Value = "点号"
ExcelSheet.Cells(1, 2).Value = "方位"
ExcelSheet.Cells(1, 3).Value = "平距"
ExcelSheet.Cells(1, 4).Value = "高程"
DIS = 0
For i = 1 To 200
ExcelSheet.Cells(i + 1, 1).Value = i
pt(i) = vbCrLf & "捕捉剖面图切点:"
hint(i) = ThisDrawing.Utility.GetPoint(, pt(i))
H(i) = vbCrLf & "输入该点高程(结束请输入“0”):"
On Error Resume Next
Hi(i) = ThisDrawing.Utility.GetReal(H(i))
If Hi(i) = 0 Then Exit For
ExcelSheet.Cells(i + 1, 4).Value = Hi(i)
If i > 1 Then
DIS = GetDIS(hint(i), hint(i - 1)) + DIS
angle = GetAngle(hint(i - 1), hint(i))
End If
If i > 1 Then ExcelSheet.Cells(i, 2).Value = Format(angle, "###")
ExcelSheet.Cells(i + 1, 3).Value = Format(DIS, "####.00")
Next i
' Close the recordset and the database connection
ExcelWorkbook.Close
Excel.Application.Quit
End Sub
我希望在红字处弹出EXCEL保存对话框,哪位大哥能告诉我。小弟在此谢过了。!!!
|
|