You are here: COM API reference > Client objects > AMDocumentUI object

AMDocumentUI object

The AMDocumentUI object provides commonly used functionality to manipulate document objects.

Supported Interfaces

IAMEdmUICache interface

IAMDocumentUISync interface

Remarks

The sample code below demonstrates how to use an AMDocumentUI object.

AMDocumentUI is a client-side object. Before it can be used, it must be initialized with an AMDocument object server object.

Example

The LoadDocument procedure uses AMDocumentUI to replace the content of a document in the vault with a file from the file system.

' Download a document from the vault to a local file
Public Sub Document2File(ByVal doc As AMDocument, ByVal file As String)
    Dim docui As New AMDocumentUI
    Dim uiStorage As AMUIStorage
    'Initialize the UI object with the Server object
    docui.Init doc
    'Get Storage Interface
    Set uiStorage = docui
    'Load the file content into the AMDocument
    uiStorage.SaveToFile file
End Sub
' Upload a local file to the vault
Public Sub File2Document(ByVal doc As AMDocument, ByVal file As String)
    Dim docui As New AMDocumentUI
    Dim uiStorage As AMUIStorage
    'Initialize the UI object with the Server object
    docui.Init doc
    'Get Storage Interface
    Set uiStorage = docui
    'Load the file content into the AMDocument
    uiStorage.LoadFromFile file
End Sub
' A function that uses the procedures above to append a line to a text document
Private Sub EditDocument(ByVal doc As AMDocument)

    Dim TempFolder As String
    Dim DocPath As String
    Dim fs As New FileSystemObject

    ' Get user’s temp folder
    TempFolder = fs.GetSpecialFolder(2)
   
    DocPath = TempFolder & "\" & doc.DisplayName

    If fs.FileExists(DocPath) Then
        fs.DeleteFile DocPath, True
    End If

    ' Download the document content
    Document2File doc, DocPath
    If fs.FileExists(DocPath) Then
        ' Edit the local file
        AppendLineToTextFile DocPath, "Edited : " & Now
        ' Upload the modified file to the vault
        File2Document doc, DocPath
        'Remove the temporary file
        fs.DeleteFile DocPath, True
    End If

End Sub
Public Sub AppendLineToTextFile(file As String, line As String)
    Dim fso As New FileSystemObject
    Dim ts As TextStream

    Set ts = fso.OpenTextFile(file, ForAppending, True)
    ts.WriteLine line
    ts.Close
End Sub

www.bluecieloecm.com