For some reasons such as the corresponding components are removed/suppressed, the dimensions which ever attach to the components will be orphaned and can be removed.
Recently, I got a question that the user wants to hide the orphaned dimension. Once the components are available again, he wants to display the dimension again.
DrawingDimension.Attached indicates whether this dimension is attached to anything. But there is no property to control the visibility of the dimension. You can only remove it completely by DrawingDimension.Delete
After some investigations, a workaround came to my brain. We could move the orphaned dimension to a layer which is switched off. And set its layer back to a normal dimension layer if the user wants to reset.
The following is some code snippet of iLogic.
****************************
hideUnAttachedDim:
doc = ThisDoc.Document ''assume a layer named "Dimension (ISO)" exists. ' If no, you could use other existing layers. Dim oHideLayer oHideLayer = doc.StylesManager.Layers.
Item("Dimension (ISO)").Copy("dummy") 'iterate each dimension Dim oEachDim As DrawingDimension For Each oEachDim In doc.ActiveSheet.DrawingDimensions 'if it is orphaned If Not oEachDim.Attached Then ' set the layer to the dummy layer oEachDim.Layer = oHideLayer End If Next 'hide this layer oHideLayer.Visible = False doc.Update
*****************************
resetDim:
doc = ThisDoc.Document 'Set the dimensions whose layer Is
'"dummy" To "Dimension (ISO)" Dim oEachDim As DrawingDimension For Each oEachDim In doc.ActiveSheet.DrawingDimensions If oEachDim.Layer.Name = "dummy" Then oEachDim.Layer = doc.StylesManager.Layers.
Item(""Dimension (ISO)") End If Next doc.Update
********************************