怎么把VB中text文本框内的多行数据导入到Excel中?在Excel中可以实现多行数据。 20
2个回答
展开全部
在vb引用窗口中,引用Excel的DLL文件
【工程】-【引用】-microsoft excel 11.0 object library
然后代码中。
Private Sub Form_Load()
Dim ex As New Excel.Application
Dim wb As Excel.Workbook
Dim sh As Excel.Worksheet
Set wb = ex.Workbooks.Add("")
Set sh = wb.Worksheets(1)
a = Split(text1.Text, vbCrLf)
For i = 0 To UBound(a)
sh.Cells(1, i + 1) = a(i)
Next
Set sh = Nothing
Set wb = Nothing
Set ex = Nothing
End Sub
【工程】-【引用】-microsoft excel 11.0 object library
然后代码中。
Private Sub Form_Load()
Dim ex As New Excel.Application
Dim wb As Excel.Workbook
Dim sh As Excel.Worksheet
Set wb = ex.Workbooks.Add("")
Set sh = wb.Worksheets(1)
a = Split(text1.Text, vbCrLf)
For i = 0 To UBound(a)
sh.Cells(1, i + 1) = a(i)
Next
Set sh = Nothing
Set wb = Nothing
Set ex = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询