如何等待excelSheet.cell(x,y)初始化 [英] how to wait for excelSheet.cell(x,y) to initialsie

查看:88
本文介绍了如何等待excelSheet.cell(x,y)初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在使用VB6代码,该代码将数据从RecordSet写入excelsheet.cells.
实际上正在写入大量数据.当数据较少时,不会发生任何问题,但是当要写入800列和12行以上时,会出现错误1004应用程序定义或对象定义的错误".
我为此错误进行了很多搜索,最后在从记录集读取的数据写入单元格之前引入了延迟(此数据只是一个数字)
尽管一切正常,但延迟了0.01 s BUT
延迟是硬编码的,我想避免它,因为它会增加时间.

是否可以使用任何API或任何方式,任何方法来等待excelsheet.cells初始化,然后继续填写数据.

可能类似于"bool cellinitialized(excelsheet.cell(x,y))"
任何帮助将不胜感激.在此先感谢.

代码是这样的:

Hi all,
i am working with VB6 code which writes data to excelsheet.cells from a RecordSet.
actually a lot of data is being written .when the data is less no problem occurs but when more than 800 columns and 12 rows are to be written then i get error 1004 "Application defined or object defined error".
i searched a lot for this error and finally introduced a delay just before writing to cells the data read from recordset(this data is just a number)
Although everything works fine with a 0.01 s delay BUT
the delay is hardcoded and i want to avoid it as it increases the time.

IS there any API or any way,any method by which i can wait for the excelsheet.cells to initialise and then go ahead with filling in the data.

may be something like "bool cellinitialized(excelsheet.cell(x,y))"
Any help will be highly appreciated.Thanks in advance.

code goes like this :

If Not IsNull(RecordSet(z).value) Then
Delay (10)'  this delay is simple function to get time delay
          ' i want to do away with this delay
          'and use some api or method instead which can signal to go ahead only 
        'when the excelsheet Cell has been initialized

excelSheet.cells(x,y)=RecordSet(z)

'x,y,z are variables for the loop

推荐答案


我想我明白了.我需要的只是Application.DoEvents().
它现在可以正常工作,但必须继续寻找.
陷入困境的任何人都可以在这里查看
http://www.mrexcel.com/forum/showthread.php?t=19342 [ ^ ]

感谢您看这个问题.
hi guys,
i think i got it . all i needed was Application.DoEvents().
its working for now but will have to keep looking.
anyone interseted can look here
http://www.mrexcel.com/forum/showthread.php?t=19342[^]

thanks for looking at this question.


这篇关于如何等待excelSheet.cell(x,y)初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆