Page orientation bug when looping through sections


I've come across a bug when looping through sections in a document that has differing page orientations. If a document contains sections whose page orientation is consistantly landscape or portrait throughout, the problem does not occur. Here's the code that causes the problem:

Dim oDoc As Document = new Document(...)
Dim oSection As Section

For Each oSection In oDoc.Sections

When the loop reaches a section with a differing page orientation an error occurs stating "Operation is not valid due to the current state of the object". I've managed to get around the issue by using a "For ... To ..." statement, but I thought you should be aware of this issue as it's something that ought to be looked at.



Thanks, Steve. I’ll check this out.