I have a Visual Basic program in Excel which opens Word documents and copies information from Word into Excel. At its heart is a for loop which goes through each table in one document. Inside the for loop is a call to a function to process that table:
For nCurrentTable = 1 To nTotalTable ' Process each table in Word document, one at a time. Call Process_One_Table(nCurrentTable, nTotalTable, vDocName) Next nCurrentTable
The n variables are Longs, vDocName is a Variant.
Why is the script exiting that function to go to the next at the end of the for loop? It has happened at various points. Right now it occurs after (code from deep in
Cells(1, nColumn).Select Selection.EntireColumn
It also occurred after I misused an assignment, assigning a String to a Long (which I've now corrected).
preguntado el 01 de febrero de 12 a las 22:02
Reinstate Monica - Goodbye SE
On Error Resume Next in the calling procedure is the most likely cause of this. If the called procedure raises an error, execution resumes at the next line of the calling procedure.