Returns an instance of the Document object corresponding to the next document in the document collection of the application.
Applies to: Application object
[[Set] documentRet =] object.NextDoc () |
The NextDoc method syntax has these parts:
Part | Description |
object | Required. An expression, that returns an instance of the Application object. |
documentRet |
Optional. A Document type variable. |
Note, that FirstDoc method must be called prior to using the NextDoc method, otherwise the NextDoc method will return Nothing. The NextDoc method also returns Nothing when the end of the list of the open documents is reached. It's convenient to use the NextDoc method together with the FirstDoc method to go through all documents open in the application.
This example contains a application-level script. The script adds a page in each other document, open in the application. The FirstDoc and NextDoc methods are used to go through document.
Dim curDoc As Document ' Declare variables Set curDoc = thisApp.FirstDoc() ' Get first document While curDoc <> Nothing ' Loop through all documents curDoc = thisApp.NextDoc() ' Get next document If curDoc <> Nothing Then curDoc.AddPage() ' Add page thisApp.NextDoc() ' Skip next document End If Wend |
See Also |
CloseDoc method, CreateNewDoc method, Doc method, DocByName method, DocsNum method, FirstDoc method, OpenDoc method, Document object |