1

Is there any way in VBA to list the files stored in a particular folder on Worksite/iManage by referencing a FolderID?

What I would like to achieve is to get all files and list them in the spreadsheet in column A just like you can get the contents of a folder from an ordinary disk directory.

In imanage the file name would be iManDocument.Description.

Below is what I have come up with so far. I don't know how to move forward with this :(

Dim dmsRoot As IManDMS
Dim dmsSession As IManSession
Dim dmsDatabase As IManDatabase
Dim iFile As IManDocument
Dim iFdr as ImanFolder
DimFname as String

Const ServerName As String = "DMSname"
Const DatabaseName As String = "DatabaseName"
Const ifID as long = "123456"

Set dmsRoot = New ManDMS
Set dmsSession = dmsRoot.Sessions.Add(ServerName)
dmsSession.TrustedLogin

Set dmsDatabase = dmsSession.Databases.ItemByName(DatabaseName)

Set iFlr = dmsDatabase.GetFolder(ifID)

What I normally would do is create a loop

For each iFile in iFlr

  Fname = IFile.Description

and put the name in cells one by one but the ImanFolder doesn't seem to have such properties.

Some help wih this would be really appreciated.

LukaszPe
  • 57
  • 1
  • 16

1 Answers1

1

IManage folders have a Contents property that contains the items stored in it. You can enumerate through the contents, casting to a IManDocument where possible, and getting the properties from that. Something akin to the following should work:

Dim folderItem As IManContent
Dim currentImanDoc As IManDocument

.... Get your folder  

For Each folderItem In currentIManFolder.Contents
    FName = folderItem .Description
Next
G Davison
  • 1,079
  • 1
  • 14
  • 21
  • Hey. Thanks a lot for your time and guidance. I tried out the code and I have a problem with the function TryCast. It' unidentified by VBA. I looked through the object browser and I can't seeem to find anything similar like DirectCast or CType. I have Excel 2010 at work and I've never used TryCast. Does this require additional library referencing? Also, I have some doubts if this is going to enlist all the items in the folder. Is there anyway to rewrite the code without the TryCast method? – LukaszPe Jan 17 '18 at 18:04
  • Apologies, I actually coded it in VB.NET as that's what I had to hand. I'll have a think about the true VBA equivalent. – G Davison Jan 17 '18 at 18:05
  • Oh. That's why I was confused a bit. Thank you again for a prompt resonse. VBA was actually the thing I was after from the beginning. I wanted the code we're working on to be a part of a larger programme but still in VBA ;-) – LukaszPe Jan 17 '18 at 18:07
  • Do you think going towards writing class modules would be a good idea? As far as I understand your code you wanted to check with TryCast if the folderItem "fits" IManDocument and can be implemented into the IManDocumented object somehow? – LukaszPe Jan 17 '18 at 18:17
  • That might just have been overkill on my part. I'll update the code with the VBA version, you're almost there with what you have. – G Davison Jan 17 '18 at 18:25
  • Hey. I got the impression that you were about to come up with a an idea for the VBA version of your code, meaning you alredy had sth in mind? I could really use your help... – LukaszPe Jan 19 '18 at 17:04
  • I updated the code above, it really is just enumerating the Contents property to get the documents out. – G Davison Jan 19 '18 at 17:05
  • OK. I got the code now. Sorry for the confusion. I corrected the command myself because it only worked when you declare folderitem as ImanDocument and not ImanContent. Now it works perfect. Thank you so much!! You're a lifesaver – LukaszPe Jan 19 '18 at 17:34