AnsweredAssumed Answered

Cannot delete all dimensions in a cell

Question asked by olsmir on Aug 30, 2013
Latest reply on Sep 2, 2013 by olsmir

I need to delete all dimensions in a cell (in the Central Library) using Аutomation. For this, I have opened the Central Library in Library Manager and run the following script (a cell name is "test").

Here I attempted two methods of deletion (see comments in a script), but without any success. Has anybody attempted to delete the dimensions in a cell using Automation?


Option Explicit

 

Dim app,lib,doc
Dim cellEditor,cellDB
Dim partition,cell,aaa

Set app = GetObject (,"LibraryManager.Application")
Scripting.AddTypeLibrary ("LibraryManager.Application")
Set lib = app.ActiveLibrary


Set cellEditor = CreateObject("CellEditorAddin.CellEditorDlg")
Scripting.AddTypeLibrary ("MGCPCBLibraries.CellEditorDlg")
Set cellDB = cellEditor.OpenDatabase(lib.FullName, False)
cellEditor.Visible = False

Call Scripting.AddTypeLibrary("MGCPCB.Application")

For Each partition In cellDB.Partitions
    For Each cell In partition.Cells
        If (cell.Name = "test") Then

           Set doc = cell.Edit()
           'Now let's delete all the dimensions (if they exist):

           If (doc.Dimensions.Count > 0) Then
              MsgBox doc.Dimensions.Count & " dimensions are detected, let's delete them...", 0, ""

              'First method: delete the dimensions all at once:
              Set aaa = doc.Dimensions
              aaa.Delete()

              'Second method: delete the dimensions one by one:
              'For Each aaa In doc.Dimensions
              '    aaa.Delete()
              'Next

              MsgBox "After deleting, " & doc.Dimensions.Count & " dimensions are detected, should be 0", 0, ""
           Else
              MsgBox "Nothing to delete", 0, ""
           End If

        End If
        doc.Close
    Next
Next

cellEditor.Quit

Outcomes