DocsNum Method

Returns the number of open documents in the application.

Applies to: Application object

Syntax

[[Set] countRet =] object.DocsNum ()

The DocsNum method syntax has these parts:

Part Description
object Required. An expression that returns an instance of the Application object.

countRet

Optional. A Long type variable.

Remarks

It's convenient to use the DocsNum method together with the Doc method to go through the open documents in the application.

Example

This example contains an application-level script. It displays the number of windows for each of the documents open in the application, the number of the open documents and the total number of document views in the application.

Dim curDoc As Document                       ' Declare variables
Dim resStr As String
Dim vcount As Integer

TRACE "----------------------------------------"
vcount = 0
For i=1 To thisApp.DocsNum()                 ' Loop through all documents
    Set curDoc = thisApp.Doc(i)              ' Get next document
    TRACE curDoc.Name & "  --  " & curDoc.ViewsNum() ' Display the number of views of each document
    vcount = vcount + curDoc.ViewsNum()
Next i
                                             ' Display the number of documents
TRACE "Count of documens = " & thisApp.DocsNum
TRACE "Count of views = " & vcount           ' Display the number of document windows
TRACE "----------------------------------------"

 

See Also

CloseDoc method, CreateNewDoc method, Doc method, DocByName method, FirstDoc method, NextDoc method, OpenDoc method, Document object