求助VB中Text中的数据怎么样保存到excel中
就是当我点击command1按钮时text中的数据就保存到excel中去了。要求我保存到excel的数据不能重叠,而且是要往右边排下去!...
就是当我点击command1按钮时text中的数据就保存到excel中去了。要求我保存到excel的数据不能重叠,而且是要往右边排下去!
展开
3个回答
展开全部
Option Explicit
Dim xlapp As Variant
Dim xlBook As Variant
Dim xlSheet As Variant
Dim i As Integer
Private Sub Command1_Click()
i = i + 1
xlSheet.Cells(1, i) = Text1.Text
End Sub
Private Sub Form_Load()
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.worksheets(1)
End Sub
Private Sub Form_Unload(Cancel As Integer)
xlapp.Quit '关闭EXCEL
Set xlapp = Nothing '释放EXCEL对象
End Sub
Dim xlapp As Variant
Dim xlBook As Variant
Dim xlSheet As Variant
Dim i As Integer
Private Sub Command1_Click()
i = i + 1
xlSheet.Cells(1, i) = Text1.Text
End Sub
Private Sub Form_Load()
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.worksheets(1)
End Sub
Private Sub Form_Unload(Cancel As Integer)
xlapp.Quit '关闭EXCEL
Set xlapp = Nothing '释放EXCEL对象
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询