I have VBA code designed to go one page at a time through the project to execute functions in a loop. At the end of the loop, we run a next page function and use a DoEvents to wait for the next page to open before running through the loop again. The problem is that the DoEvents doesn't completely do all events in the next page and therefore just ends our loop. Below is our last part of our Do loop. It appears that after invoking next page function, the VBA does wait for the next page function, but then because there is an automatic page refresh or regen, this interrupts the VBA. Is there something else going on with a next page command that we need to account for?
'Check for current drawing name strThisDrawingName = ThisDrawing.Name 'Issue command to move to next page ThisDrawing.SendCommand "ECAD_EXEC_NEXTPAGE" & vbCr 'Allows nextpage command to function DoEvents 'Check if next page drawing name is the same as previous drawing name. If they are the same, exit loop strNextDrawingName = ThisDrawing.Name If strThisDrawingName = strNextDrawingName Then Exit Do End If