我要把VB中的数据保存到EXCEL中去,求过程
来源:百度知道 编辑:UC知道 时间:2024/09/22 16:45:30
请教:
我要将VB中
Form1 中 TEXT1(0~10)中的内容添加到EXCEL中的A1~A11中去,然后好保存退出。
重点是保存退出部分。请指教。
~~~~~~~~
能通过的追加给分:)
先谢谢大家了!
我要将VB中
Form1 中 TEXT1(0~10)中的内容添加到EXCEL中的A1~A11中去,然后好保存退出。
重点是保存退出部分。请指教。
~~~~~~~~
能通过的追加给分:)
先谢谢大家了!
需要引用 Microsoft Excel 11.0 Object (Excel 2003)
Dim Ex As Object
Dim ExBook As Object
Dim ExSheet As Object
private sub commandbutton1_click()
Set Ex = CreateObject("Excel.Application")
Set ExBook = Ex.Workbooks().Add
Set ExSheet = ExBook.Worksheets("Sheet1") //打开
for i = 0 to 10
ExSheet.cells(i+1,1).Value = a(i)
next i //赋值
ActiveWorkbook.SaveAs ("d:\my.xls") //保存
Ex.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xls = Nothing //退出
end sub