yidianwen 发表于 2006-3-9 16:04:00

在VBA中引用EXCEL 对象后如何弹出EXCEL保存对话框?

我是一个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保存对话框,哪位大哥能告诉我。小弟在此谢过了。!!!

zhu1 发表于 2006-3-9 18:15:00

你可以调用VB中的保存对话框呀

yidianwen 发表于 2006-3-9 22:02:00

实在是不好意思,zhul,我也不知道如何调用VB中的保存对话框,望指点,多谢多谢

yidianwen 发表于 2006-3-10 10:52:00

多谢,我经过一宿的研究终于搞定。多谢了,zhul

xinghesnak 发表于 2006-3-11 10:53:00

要是不会调用保存对话框就自己做一个Form,也是个变通的方法,速度也不会慢到哪去......
页: [1]
查看完整版本: 在VBA中引用EXCEL 对象后如何弹出EXCEL保存对话框?