我必须捕捉with块内的错误。我正在读取一个文件,并将其添加到表格中,然后将这些记录添加到表格中。如果出现任何错误移到下一行文件On Error not in vba
Do Until EOF(1)
Line Input #1, strTextLine
'regex.replaces will replace the commas outside quotes with <???> and then the Split function will split the result based on our replacement
regex.Pattern = ",(?=([^""]*""[^""]*"")*(?![^""]*""))"
strArray = Split(regex.Replace(strTextLine, "<???>"), "<???>")
Set rs = db("ATC").OpenRecordset
With rs
.AddNew
On Error GoTo lpp
!ATC_ID = Replace(strArray(0), """", "")
!ATC_NAME = Replace(strArray(1), """", "")
.update
.Close
End With
lpp:
'goto next line in the file
Loop
看看[这里](http://stackoverflow.com/a/41553765/4926357)或者[这里](HTTP:// stackoverflow.com/a/42457284/4926357) –
@ASH已完成 – Faisal
如果此块位于循环内部,您可能错误地处理了错误,请尝试显示一些循环的代码。 –