SPCFolder.DetachEx

This function detaches the passed object from this system view folder (with audit log explanation).

Syntax Parameters Return Value
Sub SPCFolder.DetachEx( _
    Object As Variant, _
    UpdateInfo As FolderUpdateInfo)
  • Object [in]

The single item to detach.

Type: Variant

  • UpdateInfo [in]

The explanation for this operation (used for SDMS logging).

Type: FolderUpdateInfo

This function does not return a value.

SVB Example

Moving the contents of one folder to another:

Sub Main
    Dim oOM As ObjectManager

    'Reconnect into Enterprise ObjectManager
    Set oOM = New ObjectManager
    oOM.Reconnect Application

    'The folder whose content will be moved
    Dim MyFolder As SPCFolder
    Set MyFolder = oOM.FindFolder("/Blake's Materials")
    If (MyFolder Is Nothing) Then
        MsgBox "Can't find the personal folder"
        Exit All
    End If

    'The folder to move the content to
    Dim CompanyFolder As SPCFolder
    Set CompanyFolder = oOM.FindFolder("/Company Materials")
    If (CompanyFolder Is Nothing) Then
        MsgBox "Can't find the company folder"
        Exit All
    End If

    'Retrieve the folder's content
    Dim MyContent
    Set MyContent = MyFolder.List(swcBinaryDocument Or swcCharacteristic Or swcDashboard Or swcFolder Or swcLabel Or swcMonitor Or swcProfile Or swcStandardProfileSequence Or swcTaskset)

    'Start moving the content
    Dim moveInfo As New FolderUpdateInfo
    moveInfo.AuditLogReason = "Moving my content to Company folder"
    Dim i As Long
    oOM.Transaction.Start
    On Error GoTo rollback
    For i = LBound(MyContent) To UBound(MyContent)
        If (TypeName(MyContent(i)) = "SPCFolder") Then
            'NOTE: COMMENT OUT THE FOLLOWING LINE IF YOU DON'T WANT TO MOVE SUBFOLDERS
            'Also, it should be noted that DetachEx/AttachEx do not work with SPCFolder objects,
            'you must use MoveFolderEx for these.
            MyContent(i).MoveFolderEx(CompanyFolder,moveInfo)
        Else
            MyFolder.DetachEx(MyContent(i), moveInfo)
            CompanyFolder.AttachEx(MyContent(i), moveInfo)
        End If
    Next

    oOM.Transaction.Commit

    rollback:
    oOM.Transaction.Rollback

    oOM.Disconnect

End Sub