Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
checkin ... Help Required
shahbm
'I am having trouble checking in the Word document...
'here is my code----
'00000000000000000000000000000000000000000000000000000000
Private Sub ICommand_Execute()
On Error GoTo ExecuteError
'--------------My Code which creates a copy of word document from desksite, stores into my local drive, opens it and then close the copy of the document -------------------
Dim rpSelectedNRTDocuments() As IManage.NRTDocument
Dim pDocument As Variant
Dim sDisplay As String
Dim strdoc As String
Dim ocWord As Word.Application
Set ocWord = New Word.Application
rpSelectedNRTDocuments = mContext("SelectedNRTDocuments")
On Error GoTo ExecuteError
For Each pDocument In rpSelectedNRTDocuments
If pType = "WORD" Then
pDocument.GetCopy "c:\Temp\" & pDes & ".doc", imGetCopyOptions.imNativeFormat
ocWord.Application.Documents.Open ("c:\Temp\" & pDes & ".doc")
ocWord.ActiveDocument.Close
End If
'-----------------------Now I am trying to checkin the copy of the document I have created on my local drive----------------------------------------------
Dim dms As New ManDMS
Dim mySession As IManSession
Dim db As IManDatabase
Dim myWS As IManWorkspace
Dim myWorkarea As IManWorkArea
Set mySession = dms.Sessions.Add("servername")
mySession.TrustedLogin
Set myWorkarea = mySession.WorkArea
Set myWS = mySession.WorkArea.RecentWorkspaces.ItemByIndex(1)
Dim myDoc As IManDocument
Dim errs
Set myDoc = myWS.Database.CreateDocument()
'---------------CODE WORKS TILL HERE AND THEN THROWS AN ERROR (Manage32: Type mismatch)----------------------------------------here is an error-----------------
myDoc.SetAttributeByID imProfileAttributeID.imProfileAuthor, "temp"
myDoc.SetAttributeByID imProfileAttributeID.imProfileOperator, "temp"
myDoc.SetAttributeByID imProfileAttributeID.imProfileClass, "DOC"
myDoc.SetAttributeByID imProfileAttributeID.imProfileType, "Word"
' myDoc.Description = "Temp Test"
Set myDoc = myDoc.CheckIn("c:\Temp\" & pDes & ".doc", imReplaceOriginal, imDontKeepCheckedOut, errs)
If Not errs <> "" Then
MsgBox ("Errors while checkin...")
End If
'-----------------------------------------------------------------------------executing OpenCmd now from iManage--------------------------------------
' Dim objOpencmd As IMANEXTLib.OpenCmd
' Set objOpencmd = New IMANEXTLib.OpenCmd
'
' mContext.Add "ParentWindows", 0
' objOpencmd.Initialize mContext
' objOpencmd.Update
'
' If objOpencmd.Status = nrActiveCommand Then 'objOpencmd.Status And
'
' objOpencmd.Execute
' mContext.Remove "NRTExt.Refresh"
'
' End If
Next pDocument
GoTo ExecuteError
ExecuteError:
If Err.Description <> "" Then
MsgBox Err.Description + Err.Number, , "Error in execute !!"
End If
' Set objOpencmd = Nothing
' Set pDocument = Nothing
Err.Clear
Exit Sub
End Sub
'Can someone tell me why its throwing an error and how do i fix it...
Thax
Find more posts tagged with
Comments
jny
As it looks, this is what you're actually doing in your code:
You are creating a new document profile object and uploading the newly created Word file to WorkSite, yet you're setting the upload option to 'replace original'...which will fail because the document object has never been checked out -- so there isn't any document object with which to replace.
Keep in mind that the only WorkSite document that is or has been opened is the one referenced by the pDocument variable; myDoc is a brand new document object that has never been opened or checked out.
I'm not too clear on exactly what you're trying to accomplish but your code logic does not seem 'logical'.
If you could explain what you're attempting to do, perhaps I can help with how you can do it.
shahbm
Hi jny,
thx for your reply,
i know my code dosen't seem to be logical as this is what i thought - to achieve what i wanted to do!!
what i want..is.....
1. when i open a word document from desksite, before iMan OpenCmd executes, i want to attach a custom word template to that file...
(so i m creating a local copy and when i open that copy, my template will be attached to that copy...through my add-in )
2. now the copy i have created with my custom template must be checkin, replacing the original document, so that when iMan OpenCmd executes - the document will have my template attached to it.....
3. i was unsure how to checkin the document and it was just my guess to checkin by creating another document ,,, but i m sure that must be some other way around...
...
can u suggest what i should do to checkin the copy of that document??
regards,
shahbm
jny
Actually, on a second look, the selected documents are actually never checked out yet until you call OpenCmd (which is never reached in your current implementation logic).
At any rate, since, in your ICommand_Execute, you're switching the file associated with each selected WorkSite document object before opening them, try:
1. calling CheckOut on each WorkSite document, pDocument
2. calling your WOM implementation logic
3. calling Checkin to uploade the templated file/replace original on pDocument
4. passing the checked-in documents to the OpenCmd object.
ex//
Dim result As IManCheckinResult
...
pDocument.Checkout "c:\Temp\" & pDes & ".doc", imReplaceExistingFile, Now, "No Comment"
// TODO: implement your WOM code.
result = pdocument.CheckInWithResults(pdocument.CheckoutPath, imCheckinReplaceDocumentOnly, imDontKeepCheckedOut)
If False = result.Succeeded Then
'There's a problem with checkin...debug;Otherwise, move on to the next document.
End If
' Now, you should be able to call OpenCmd to open the replaced file in Word.
Keep in mind that you should take care of cleaning up the downloaded files (which happen on the Checkout call) in your local directory.
There is a caveat to this approach: you will have a history of two checkout logs on each selected document. One is from your Checkout call and the other is from invoking the OpenCmd.
Hope this helps.
shahbm
Thank you very much jny,
actually this is exactly we thought yesterday and i hope it will work...
many thax again,
shahbm
shahbm
It indeed worked...
thx heeps jny,
shahbm