VB编程excel问题,为什么同时打开两个表,一个是已有的“记录”,另一个是"book1"
PrivateSubCommand1_Click()SetxlApp=CreateObject("Excel.Application")'创建EXCEL对象SetxlBo...
Private Sub Command1_Click()Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象Set xlBook = xlApp.Workbooks.Open(App.Path & "\记录") '打开已经存在的EXCEL工件簿文件xlApp.Visible = True '设置EXCEL对象可见(或不可见)Set xlSheet = xlBook.Worksheets("sheet1") '设置活动工作表xlApp.Workbooks.AddxlSheet.Cells(1, 1) = "时间"xlSheet.Cells(1, 2) = "电流"xlSheet.Cells(1, 3) = "温度"k = 2Timer2.Enabled = TrueEnd Sub
展开
2013-08-05
展开全部
Private Sub Command1_Click()
Set xlapp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlapp.Workbooks.Open(App.Path & "\记录.xls") '打开已经存在的EXCEL工件簿文件
xlapp.Visible = True '设置EXCEL对象可见(或不可见)
Set xlsheet = xlBook.Worksheets("sheet1") '设置活动工作表
'xlapp.Workbooks.Add
xlsheet.Cells(1, 1) = "时间"
xlsheet.Cells(1, 2) = "电流"
xlsheet.Cells(1, 3) = "温度"
k = 2
Timer2.Enabled = True
End Sub
注释掉xlapp.Workbooks.Add
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询