Recurring Instances Macro
Recurring Instances Macro
Recurring Instances Macro
Application.ScreenUpdating = True
Dim ModeRecalcul As Long
ModeRecalcul = Application.Calculation
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = False
'Purge existing data
Sheets("Recurring Instance List").Range("A3:L65000").ClearContents
'Session Manager declaration
Dim SessionManager, Sess As SessionMgr
'Enterprise Session declaration
Dim esession As EnterpriseSession
RowNum = RowNum + 1
Rng(1, 5) = RowNum - 2
Rng(RowNum, 1) = Mid(rsRow2.Properties("SI_PROGID"), 19, Len(rsRow2.Prop
erties("SI_PROGID")))
Rng(RowNum, 2) = rsRow2.Properties("SI_ID")
Rng(RowNum, 3) = rsRow2.Properties("SI_NAME")
Rng(RowNum, 4) = rsRow2.Properties("SI_UPDATE_TS")
Rng(RowNum, 5) = rsRow2.Properties("SI_CREATION_TIME")
'------------------------------------------------------------------------
'Get the Path
'------------------------------------------------------------------------
ParentFolderID = rsRow2.ParentID
Set tempObj = iStore.Query("SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOO
BJECTS WHERE SI_ID=" & ParentFolderID)
ParentFolderID = tempObj.Item(1).ParentID
Path = "/" + tempObj.Item(1).Title + Path
Do While ParentFolderID <> 0 And ParentFolderID <> 4
Set tempObj = iStore.Query("SELECT SI_PATH, SI_NAME FROM CI_INFOOBJECTS
WHERE SI_ID=" & ParentFolderID)
Path = "/" + tempObj.Item(1).Title + Path
ParentFolderID = tempObj.Item(1).ParentID
Loop
Path = "Home" & Path
Rng(RowNum, 6) = Path
Path = ""
Rng(RowNum, 7) = rsRow.Properties("SI_ID")
Rng(RowNum, 8) = rsRow.Properties("SI_NAME")
'-----------------------------------------------
'Get the prompt info
'---Turned off in this version-----
'---------------------------------------------
intEventCount = oScheduleInfo.Properties("SI_DEPENDENCIES").Properties("SI_TOTA
L").Value
For x = 1 To intEventCount
strEventNum = x
tempObj = iStore.Query("SELECT SI_NAME FROM CI_SYSTEMOBJECTS WHERE SI_
ID=" & oScheduleInfo.Properties("SI_DEPENDENCIES").Properties(strEventNum).Value
)
strEventName = tempObj.Properties("SI_NAME").Value
strEventList = strEventList & strEventName & Chr(59)
Next x
Rng(RowNum, 10) = strEventList
strEventList = ""
Else
'Do Nothing
End If
intEventCount = 0
'---Obtain destination email addresses:
If oScheduleInfo.Properties("SI_DESTINATIONS").Properties("SI_TOTAL").Value =
1 Then
'-----------------
If oScheduleInfo.Properties("SI_DESTINATIONS").Properties("1").Propertie
s("SI_PROGID") = "CrystalEnterprise.Smtp" Then
Rng(RowNum, 11) = oScheduleInfo.Properties("SI_DESTINATIONS").Proper
ties("1").Properties("SI_DEST_SCHEDULEOPTIONS").Properties("SI_MAIL_ADDRESSES").
Properties("1").Value
Else
'Do nothing
End If
'-----------------
Else
'Do Nothing
End If
'------------------------------------------------------------------------
Next rsRow2
Next rsRow
'------------------------------------------------------------------------
'Next i
'------------------------------------------------------------------------
Rng(1, 6) = "Last Execution Duration (min/sec): " & (Timer - BenchMark) / 60
Application.Calculation = ModeRecalcul
Calculate
Application.Calculation = xlCalculationManual
Application.EnableEvents = True
Me.Hide
CleanUp:
Me.Hide
On Error Resume Next
esession.Logoff
Application.Calculation = ModeRecalcul
Calculate
Application.EnableEvents = True
Exit Sub
ErrorHandler:
'Debug.Print Err.Number & " - " & Err.Description
If Err.Number = -2147210697 Then
'Debug.Print Err.Number & " - " & Err.Description
If ErrorState = "FullName" Then Rng(RowNum, 3) = "Error on Full Name"
If ErrorState = "LastLogon" Then Rng(RowNum, 9) = ""
Resume Next
End If
Me.Hide
MsgBox Err.Source & " - " & Err.Number & ": " & Err.Description & " " & Err
.HelpContext, _
vbCritical, "Failure in UsersGroups()"
Resume CleanUp
End Sub