Home
TeamSite
Create Workspace in vb6
taibooz
Hi all,
Have anyone build new workspace using vb6 ?
I'm using vb6 to search existing workspaces and add document folders but i have difficulty to usign vb6 to create new workspaces
Thanks
Find more posts tagged with
Comments
Migrateduser
Yes. We'll be releasing a powerful new product (WorkSpace Builder) that does this, with an open extensible COM object as well...
Migrateduser
Hi ,
It has left that product already? I am interested in knowing as is
Thanks
jny
Here's some VB6 example code to demo how to create a workspace and add a folder to it:
Option Explicit
Private Sub Form_Load()
Dim iDMS As New ManDMS
Dim iSess As IManSession
Dim iDB As IManDatabase
Dim iWorkspace As IManWorkspace
Dim iUpdateResult As IManProfileUpdateResult
Dim profErrs As IManProfileErrors
Dim docfldr As IManDocumentFolder
Dim strServername As String
Dim tempFile As String
strServername = " " ' server to connect
' Login
Set iSess = iDMS.Sessions.Add(strServername)
iSess.TrustedLogin
Set iDB = iSess.PreferredDatabase
' Create workspace
On Error GoTo CreateErr
Set iWorkspace = iDB.CreateWorkspace
' Populate minimum required fields
With iWorkspace
.Owner = iDB.GetUser(iSess.UserID)
.Name = "My Workspace"
.Description = "Creating my workspace through code"
.SubType = "work" ' subtype for user workspaces is always "work"
End With
tempFile = GetTempFile ' temp file for updating
' Commit workspace profile to server
Set iUpdateResult = iWorkspace.UpdateAllWithResults(tempFile)
If False = iUpdateResult.Succeeded Then GoTo Cleanup
' Add document folder
Set docfldr = iWorkspace.DocumentFolders.AddNewDocumentFolder("new folder", "test adding read-only")
docfldr.Update
' Assigning specific ACL to the added folder
Dim sec As IManSecurity
Set sec = docfldr.Security
sec.UserACLs.Add "GUEST", imRightReadWrite
docfldr.Update
MsgBox "New Workspace ID: " & iWorkspace.ID
GoTo Cleanup
CreateErr:
' Check update errors
If Not iUpdateResult Is Nothing Then
Set profErrs = iUpdateResult.ErrorList
If Not profErrs Is Nothing Then
If profErrs.Count > 0 Then
' TODO: log errors by iterating through ProfileErrors collection
MsgBox profErrs.ItemByIndex(1).AttribID & ", " & profErrs.ItemByIndex(1).Description
' Simple demo of displaying the first error
End If
End If
End If
Resume Cleanup
Cleanup:
Set profErrs = Nothing
Set iUpdateResult = Nothing
Set iWorkspace = Nothing
Set iDB = Nothing
Set iSess = Nothing
Set iDMS = Nothing
Kill tempFile
End
End Sub
Private Function GetTempFile() As String
Dim FSO As New FileSystemObject
Dim fil As TextStream
Dim filename As String
filename = FSO.GetTempName
Set fil = FSO.CreateTextFile(filename, True)
fil.Close
GetTempFile = filename
End Function