Search code examples
vbams-accessoutlooklivelink

Create a folder in Livelink with VBA


I am looking for the easiest and fastest way to create a folder in Livelink with VBA. I'm working with Microsoft Access 2003. For example, I want to create a folder into Livelink\Enterprise\folder1\folder2\. I also have the folder2 LivelinkID (7 digits) stored in my Access database. The Livelink server takes about ~1-2 seconds to respond each times I ping it.

What would be the best method to create a folder into Livelink within my VBA project? Livelink version is 9.7.1.0.814 with Livelink Explorer (Connect) 4.8.2.397, using Outlook 2003.

Thank you.


Solution

  • Finally got it working with WebDAV. It would work too with MAPI but it's really long to reach a deep parent folder (going thru folder by folder each times).

    Here is the function I got:

    Public Function CreateFolderToLLFolder(parentId As String, folderName As String) As String
        Dim dav As New ADODB.Record
        Dim elements As ADODB.Recordset
        Dim fields(1) As Variant
        Dim values(1) As Variant
    
        dav.Open URL_WEBDAV & parentId, "", adModeReadWrite, , , LLUser, LLPassword
        Set elements = dav.GetChildren
    
        fields(0) = "RESOURCE_PARSENAME"
        values(0) = folderName 
    
        fields(1) = "RESOURCE_ISCOLLECTION"
        values(1) = True
    
        elements.addnew fields, values
    
        elements.Close
        Set elements = dav.GetChildren
        dav.Close
    
        elements.MoveFirst
        Do Until elements.EOF
            If elements("RESOURCE_DISPLAYNAME") = folderName Then
                Exit Do
            End If
            elements.MoveNext
        Loop
        If Not elements.EOF Then
            dav.Open elements
            CreateFolderToLLFolder = dav("urn:x-opentext-com:ll:properties:nodeid")
        Else
            CreateFolderToLLFolder = -1
        End If
    
        dav.Close
        elements.Close
    Exit Function
    

    URL_WEBDAV is for example http://livelink.yourserver.com/livelinkdav/nodes/. Also use LLUser and LLPassword if needed.