I'm trying to save a Word document into iManage using ImportCmd from IMANEXTLib and I'm getting a new instance of Word every time I run it.
I've saved the document to doc1.doc, and then:
'Connects to WorkSite
Dim dmsConnection As IManage.IManDMS = New IManage.ManDMSClass()
dmsConnection.ApplicationName = "My Application"
Dim sesCobbDms As IManage.IManSession = dmsConnection.Sessions.Add("DMS")
sesCobbDms.TrustedLogin()
'Initialisation
Dim hwndWord As Integer
Dim strTempCaption As String = Application.Caption
Application.Caption = "Hunting For Word"
hwndWord = MyApi.FindWindow("OpusApp", Application.Caption)
Application.Caption = strTempCaption
Dim intKeepCheckedOut As Integer
Dim docJustSaved As IManage.NRTDocument
Dim objImportCmd As IMANEXTLib.ImportCmd
Dim objContextItems As New IMANEXTLib.ContextItems
'Sets up ContextItems ready for save process
objContextItems.Add("ParentWindow", hwndWord)
objContextItems.Add("DestinationObject", sesCobbDms)
objContextItems.Add("IManExt.Import.FileName", NrPort & "\Doc1.doc")
'Note that we have to check it in and then back out again, otherwise it checks out to the wrong place
intKeepCheckedOut = IManage.CheckinOptions.nrDontKeepCheckedOut
objContextItems.Add("IManExt.Import.KeepCheckedOut", intKeepCheckedOut)
'Forces a blank description
objContextItems.Add("ImanExt.Import.DocDescription", "")
objImportCmd = New IMANEXTLib.ImportCmd
objImportCmd.Initialize(objContextItems)
objImportCmd.Update()
If objImportCmd.Status = IMANEXTLib.CommandStatus.nrActiveCommand Then
'Imports the document, throwing a Save As screen at the user
objImportCmd.Execute()
And at this point, I get a new instance of Word, on top of the one I was saving from (ie, on top of Application). What gives?
Just to provide a resolution, I noticed that the problem only occurred under one user account (mine) and then I just deleted my user profile. My shiny! new! profile doesn't have the same problem.