VB保存EXCEL,第一次保存OK第二次保存替换选择‘否’就会出错,选择‘是’不出错。而且只能存一笔数据。
StaticaAsIntegerSetxlApp=CreateObject("Excel.Application")SetxlBook=xlApp.Workbooks.A...
Static a As Integer
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets("sheet1")
xlApp.Visible = True
m100 = facon.getItem("Channel0.Station0.Group0", "m100")
If m100 = True Then
a = a + 1
xlSheet.Cells(a, 1) = facon.getItem("Channel0.Station0.Group0", "R0")
xlSheet.Cells(a, 2) = facon.getItem("Channel0.Station0.Group0", "R1") xlSheet.Cells(a, 3) = facon.getItem("Channel0.Station0.Group0", "R2")
End If
xlBook.SaveAs ("C:\Documents and Settings\Administrator\桌面\10.xls") xlBook.Close (True) '
xlApp.Quit
Set xlApp = Nothing 展开
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets("sheet1")
xlApp.Visible = True
m100 = facon.getItem("Channel0.Station0.Group0", "m100")
If m100 = True Then
a = a + 1
xlSheet.Cells(a, 1) = facon.getItem("Channel0.Station0.Group0", "R0")
xlSheet.Cells(a, 2) = facon.getItem("Channel0.Station0.Group0", "R1") xlSheet.Cells(a, 3) = facon.getItem("Channel0.Station0.Group0", "R2")
End If
xlBook.SaveAs ("C:\Documents and Settings\Administrator\桌面\10.xls") xlBook.Close (True) '
xlApp.Quit
Set xlApp = Nothing 展开
1个回答
2012-01-07
展开全部
你在程序没有完全退出之前,不要xlApp.Quit
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询