用VB计算出来的数据,如何直接excel输出?
展开全部
'菜单拆稿“工程/引用”,勾选Microsoft Excel 11库,必须的
Private Sub baocun()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then Set xlApp = CreateObject("Excel.Application")
On Error GoTo prcERR
Set xlBook = xlApp.Workbooks.Open("c:\1.xls") '打开你的EXCEL文兆槐件
Set xlSheet = xlBook.Worksheets(1) '第一个表格
xlSheet.Application.Visible = True '设置Excel 可见
xlSheet.Cells(2, 1) = Text1.Text '第2行第一列旅猜孝
xlBook.Save
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Exit Sub
prcERR:
Debug.Print Err.Number & ":" & Err.Description
End Sub
Private Sub baocun()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then Set xlApp = CreateObject("Excel.Application")
On Error GoTo prcERR
Set xlBook = xlApp.Workbooks.Open("c:\1.xls") '打开你的EXCEL文兆槐件
Set xlSheet = xlBook.Worksheets(1) '第一个表格
xlSheet.Application.Visible = True '设置Excel 可见
xlSheet.Cells(2, 1) = Text1.Text '第2行第一列旅猜孝
xlBook.Save
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Exit Sub
prcERR:
Debug.Print Err.Number & ":" & Err.Description
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询