Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Using IManMoveContentsCmd To Move A Document
RedMorris
I'm writing some code to inteligently move a document to a folder when it is first saved. I'm using IManMoveContentsCmd, but have come across a problem.
The command requires a context item called SelectedContentsContainer, and it must have an IManFolder of the folder the document is currently in. But what do you do when it's in the root of the database? It does not have a folder to pass.
Find more posts tagged with
Comments
RedMorris
Found it, Database.Root
RedMorris
OK, I give up, what's wrong with this?
It runs through without error, and all the ContextItems are getting added. After the Execute a Refresh context item has been added, but that's it, and the document hasn't been added to the folder. I've tried taking out the non-essentials, but that didn't make any difference
Anyone?
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim objDMS As NRTDMS
Dim objIManDB As IManDatabase
Dim objMove As New IMANEXT2Lib.IManMoveContentsCmd
Dim objMoveContext As New ContextItems
Dim hWnd As Long
Dim objIManFolder As IManage.IManFolder
Dim objTargetFolder As IManage.IManDocumentFolder
Dim aobjDocuments(1 To 1) As IManage.IManDocument
Dim aobjIManObj() As IManage.IManObject
Set objDMS = Word.Application.COMAddIns("iManO2K.AddinForWord2000").object.Context("NRTDMS")
Set objIManDB = objDMS.Sessions(1).Databases(1)
hWnd = FindWindow("OpusApp" & Chr$(0), Chr$(0))
Rem The document is currently in the database root
Set objIManFolder = objIManDB.Root
Rem Select Document 359 v1
Set aobjDocuments(1) = objIManDB.GetDocument(359, 1)
Rem Move it to 000002/000002.000051
Set objTargetFolder = objIManDB.Workspaces.ItemByIndex(2).SubFolders.ItemByIndex(1)
With objMoveContext
.Add "ParentWindow", hWnd
.Add "SelectedContentsContainer", objIManFolder
.Add "SelectedIManObjects", aobjDocuments
.Add "SelectedTargetIManFolderObject", objTargetFolder
.Add "IManExt.NoCmdUI", True
End With
objMove.Initialize objMoveContext
objMove.Execute
Rem We added 5 context items, and Refresh gets added
Rem If these are the only items, it hasn't worked
If objMove.Context.Count > 6 Then
MsgBox "Moved to " & objIManDB.Workspaces.ItemByIndex(2).Name & "/" & _
objIManDB.Workspaces.ItemByIndex(2).SubFolders.ItemByIndex(1).Name
End If
jny
The SafeArray that holds your document objects should be of type NRTDocument; IManDocument is not yet supported.
You may also want to use Workspace.DocumentFolders to retrieve a document folder. SubFolders can contain other folder type folders, namely tab.