@BromanSillito,
Internal names of libraries are varies from one system to another. Currently, Internal name of "My Library" in your system is different . So, it need to update(highlighted in red color) in below code.
Sub CCTest()
Dim oDP As DesignProject
Set oDP = ThisApplication.DesignProjectManager.ActiveDesignProject
Dim xNode As IXMLDOMNode
Dim XDoc As MSXML2.DOMDocument
Dim strXML As String
strXML = oDP.ContentCenterConfiguration.ConfigurationXML
Set XDoc = New MSXML2.DOMDocument
If Not XDoc.LoadXML(strXML) Then 'strXML is the string with XML'
Err.Raise XDoc.parseError.ErrorCode, , XDoc.parseError.reason
End If
Set xNode = XDoc.lastChild.lastChild
Dim oNew As IXMLDOMElement
Set oNew = XDoc.createElement("Library")
Dim att As IXMLDOMAttribute
Set att = XDoc.createAttribute("DisplayName")
att.Text = "My Library" 'This is library name to be enabled.
Dim att1 As IXMLDOMAttribute
Set att1 = XDoc.createAttribute("InternalName")
att1.Text = "2f1b22d8-e1e5-4955-81d6-f1cf62eab229" 'Internal name varies from system to system.
Dim att2 As IXMLDOMAttribute
Set att2 = XDoc.createAttribute("IsReadOnly")
att2.Text = "False"
Dim att3 As IXMLDOMAttribute
Set att3 = XDoc.createAttribute("LibraryAttachName")
att3.Text = "My Library"
Dim att4 As IXMLDOMAttribute
Set att4 = XDoc.createAttribute("ServerName")
att4.Text = "DesktopContent"
Call oNew.Attributes.setNamedItem(att)
Call oNew.Attributes.setNamedItem(att1)
Call oNew.Attributes.setNamedItem(att2)
Call oNew.Attributes.setNamedItem(att3)
Call oNew.Attributes.setNamedItem(att4)
Call xNode.appendChild(oNew)
Debug.Print XDoc.xml
strXML = XDoc.xml
oDP.ContentCenterConfiguration.ConfigurationXML = strXML
End Sub
To get internal names of content center libraries, check all libraries in content center configuration and run below code. In Immediate window, it prints all Library name and internal names as well.
Sub CCTest()
Dim oDP As DesignProject
Set oDP = ThisApplication.DesignProjectManager.ActiveDesignProject
Dim xNode As IXMLDOMNode
Dim XDoc As MSXML2.DOMDocument
Debug.Print oDP.ContentCenterConfiguration.ConfigurationXML
End Sub
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network