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

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

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

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

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

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

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

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

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

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

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