|  | This macro shows you how to update sheets in Drawing documents. This macro retrieves all the drawing documents in a given folder, and
      loops on these documents to open them, update all their DrawingSheet
      objects, save and close them.   | 
  
    |  | CAADriUpdateSheets includes five steps: 
        PrologCreating a File System Object to Handle the FolderRetrieving the FolderLooping on the Drawing Documents to Update
          Their SheetsSaving and Closing the Documents Prolog
        
          |   ...
  ' Set the CATIA popup file alerts to False
  ' It prevents to stop the macro at each alert during its execution
  CATIA.DisplayFileAlerts = False
  ... |  The CATIA prompts are disabled thanks to the DisplayFileAlertsproperty of the Application object set toFalse. Creating a File System Object to Handle the Folder
        
          |   ...
  ' Set the file system object containing the folder
  Dim fileSys As FileSystem
  Set fileSys = CATIA.FileSystem 
  ... |  The FileSystemproperty of the Application object
      returns a portable object between Windows and Unix. Thanks to this object,
      a folder and its files and subfolders can be retrieved. Retrieving the Folder
        
          | ...
    ' Define the path's folder where we are looking for Drawing documents
    Dim sFolderPath As String
    sFolderPath = InputBox( "Enter a folder path:", "Update All Sheets Of a Folder" ,_
                            sDocPath & "\online\CAAScdDriUseCases\samples")
    If (Not oFileSys.FolderExists(sFolderPath)) Then
      Err.Raise 9999,,sFolderPath & ": This Folder does not exist"
    End If
    ' Set the folder object
    Dim oFolder As Folder 
    Set oFolder = oFileSys.GetFolder(sFolderPath) 
  ... |  The folder is retrieved in folderfrom thefileSysobject using theGetFoldermethod to which the folder namesFolderPathis given.sFolderPathis initialized to a documentation
      folder using an environment variable and a confirmation is requested using
      the InputBox function. TheFolderExistsmethod of theFileSystemobject is then used to check the existence of this folder. Looping on the Drawing Documents to Update Their
      Sheets
        
          | ...
     ' Loop on the files collection of the folder
    ' For Each File In Folder.Files
    Dim iI, iJ
    For iI = 1 To oFolder.Files.Count
        Dim oFile As Object
        Set oFile = oFolder.Files.Item(iI)
    
        '  Retrieve in the files collection only the Drawing documents from its extension
        If InStr(oFile.Name, ".CATDrawing") <> 0 Then
            ' Set and open a Drawing document
            Dim oDoc As Document 
            Set oDoc = CATIA.Documents.Open(oFile.Path)
            MsgBox "Updating Document " & oFile.Path, 0  ' VBOKOnly
            ' Loop on the sheets collection of the drawing document
            ' For Each sheet In oDoc.Sheets 
            For iJ = 1 To oDoc.Sheets.Count
                ' Update the sheet even is not necessary
                oDoc.Sheets.Item(iJ).ForceUpdate 
            Next
  ... |  To retrieve each file of the folder, a For ... To ... Nextloop uses theiIvariable that ranges from 1 to the number of
      files in the folder returned by theCountproperty of the
      collection of files. The collection is retrieved thanks to theFilesproperty of the Folder object. TheItemmethod of this
      collection enables you to retrieve theiIth file
      in the collection handled using theoFilevariable. Then,
      using theInStrfunction, each file name is checked for the
      ".CATDrawing" extension before being opened thanks to theOpenmethod of the Documents collection to which the file pathname is
      passed using thePathproperty of the File object. AFor
      Each ... In ... Nextembedded loop onto the sheets of the Drawing
      document uses theSheetsproperty of such as document to
      retrieve each sheet. TheForceUpdatemethod of the Sheet
      object updates the sheet, even if updating the sheet is not needed. Saving and Closing the Documents
        
          | ...
            ' Save the Drawing document
            ' oDoc.Save
            ' Close the Drawing document
            oDoc.Close
        End If
    Next
End Sub
 |  When all the sheets are processed, the drawing document is successively
      saved and closed thanks to the <.td>SaveandClosemethods of the Document object. The use ofSavemethod
      is here commented to avoid access right problems to the documentation
      files. |