vb6.0,操作excel 的问题
各位大侠,我想在一个工作簿里面加一个工作表,却不知道怎么弄,我现在的办法行不通,也不知道问题出在哪里,各位大侠给我指条明路吧现在代码如下:
Dim xlApp1 As Excel.Application
Dim xlBook1 As Excel.Workbook
Dim xlSheet1 As Excel.Worksheet
Set xlApp1 = CreateObject("Excel.Application")
Set xlBook1 = xlApp1.Workbooks.Add
xlApp1.SheetsInNewWorkbook = ChannelTemp + 1 'ChannelTemp一般等于4
xlApp1.Worksheets.Add
j = 1
For i = 0 To 7
If Channelflags(i)=True Then '最多只有四个为真
xlApp1.Visible = False
Set xlSheet1 = xlBook1.Worksheets(j)
xlSheet1.Activate
xlBook1.ActiveSheet.Name = "通道" & i & "_平均值.xls"
j = j + 1
'中间的代码就是保存数据了
End If
Next i
运行时总是提示Set xlSheet1 = xlBook1.Worksheets(j)出错,out of rang ,(此时j=4)
我用的vb6.0
谢谢了!
[[italic] 本帖最后由 dengxiaojun1 于 2007-11-29 08:48 编辑 [/italic]]