How to avoid the exception during many copy/paste in excel (VB.NET)

  • Thread starter Thread starter JayWangTPE
  • Start date Start date
J

JayWangTPE

Guest
Hi

In VB.NET, when I do copy something in excel file1 and paste it to another excel file2 in many times.

Sometimes (not always), the following exception happens. How can I fix it? Thanks in advance.


1498378.jpg

xlRange1.Copy() ' copy from excel file 1
'
ws.Activate()
Call WaitMs(100)
'
xlRange2 = ws.Range(PastLoc).Offset(, pasteColumnNo)
'Call WaitMs(100)' To paste in excel file 2
xlRange2.PasteSpecial(Excel.XlPasteType.xlPasteValues, Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, vbFalse, vbFalse)

Continue reading...
 
Back
Top