EBDN - Community - Question & Answers

  1. Eduardo Flores
  2. VBA Development
  3. Monday, 17 January 2022
Hi EB team,

I'm currently trying to obtain a list of user-modified components from VBA. For that i'm using the provided Revisions objects and functionality (RevisionsFolder and Worksheets mainly) but i have a few issues.

I create the snapshots (revisions), the following way depending if it is the first, or a new one.

Public Sub CreateZeroRevision()
Dim revData As Aucotec.RevisionData
ActiveProject.Revisions.GetNextRevisionData revData
If Not revData.ZeroRevisonIsCreated Then
revData.RevisionNames = "a-z"
revData.Date = DateTime.Now
revData.Comment = "Baseline project's snapshot."
ActiveProject.Revisions.Create revData
End If
End Sub

Public Sub CreateNewRevision()
Dim revData As Aucotec.RevisionData
ActiveProject.Revisions.GetNextRevisionData revData
revData.Date = DateTime.Now
ActiveProject.Revisions.Create revData
End Sub

After creation of the first, i expect a user to make modifications to objects in EB. On the second run of the Macro i want it to point out which items were modified with NEW, MODIFIED and DELETED. This i can get with

Public Sub CompareRevision()

Dim revFolder As ObjectItem
Set revFolder = ActiveProject.RevisionsFolder

Dim oCurrentRevision As ObjectItem
Set oCurrentRevision = revFolder.Children(revFolder.Children.count) ' Open last one
Dim oFormerRevision As ObjectItem
Set oFormerRevision = revFolder.Children(1) ' Open first

Dim compareWs As Worksheet
Set compareWs = oCurrentRevision.Children(2).OpenWorksheet(oFormerRevision.Children(2), False) ' I want to compare only the second worksheet in each revision.

Dim oDevices As ObjectItems
Dim oDevice As ObjectItem

Dim state As Integer
Dim lRow As Long
For lRow = 1 To compareWs.RowCount

state = compareWs.GetValue(lRow, 1)
Debug.Print compareWs.GetText(lRow, 1); ": " + compareWs.GetText(lRow, 2)
' compareWs.AttrStatusId(lRwow, 1)
Select Case state
Case 1
Debug.Print "New version"
Case 2
Debug.Print "Old version"
Case 3
Debug.Print "New Item"
Case 4
Debug.Print "Item erased"
Case Else
Debug.Print "????"
End Select

If state <> 4 Then
Set oDevice = compareWs.GetObjectItem(lRow)
Debug.Print oDevice.name + ": " + oDevice.Comment
End If
Next lRow

End Sub

As you can see i create a new revision each time and i try to delete it afterwards. My two issues are,

1) I don't want to create a new revision each time. Is there a way i can compare a revision with the current project as it is done through the UI: (attachment 1)

2) If it is not possible, how can i delete the created revision? The following code returns true but does not erase the Revision object.

Public Sub DeleteLastRevision()
Dim revFolder As ObjectItem
Set revFolder = ActiveProject.RevisionsFolder
End Sub

Thanks in advance,
Attachments (1)
You do not have permission to view the content of this accepted answer and replies.