'MegaContext(Fields,Types) Option Explicit Function InvokeArgCount() InvokeArgCount = 1 End Function '----------------------------------------------------------------------------- ' FUNCTION : InvokeOnObject ' Function called when the command is triggered from a MegaObject. ' Example : click on a menu. ' ' @param mgobjSource ' MegaObject on which the command is applied. '----------------------------------------------------------------------------- Function InvokeOnObject(mgobjSource as MegaObject, sUserData As Variant) Dim objExcel Dim objWorkbook Dim OrgProcesses Dim OrgProcess Dim Objectives Dim Objective Dim i Set objExcel = CreateObject("Excel.Application") MsgBox("The Objective report generation will start, click Ok to initiate" & vbCrLf & "Please wait untill the Report is shown") objExcel.Application.DisplayAlerts = False Set objWorkbook = objExcel.Workbooks.Add() Set OrgProcesses = mgobjSource.GetRoot.GetCollection("Organizational Process") objExcel.Range("A1:D3").Merge objExcel.Range("A1:D3").HorizontalAlignment = -4108 objExcel.Range("A1:D3").Borders.Color = vbBlack objExcel.Range("A1:D3").Borders.Weight = 4 objExcel.cells(1,1).value = "Process To Objective Report" objExcel.cells(5,1).value = "Org-Unit:" objExcel.cells(5,2).value = "Company Name" objExcel.cells(6,1).value = "Process ID" objExcel.cells(6,2).value = "Process Name" objExcel.cells(6,3).value = "Objective Name" i = 7 Dim ObjectivesString ObjectivesString = "" For each OrgProcess in OrgProcesses Set Objectives = OrgProcess.GetCollection("Enterprise Objective") If Objectives.Count > 0 Then ObjectivesString = "" For each Objective in Objectives ObjectivesString = ObjectivesString & Objective.GetProp("ShortName") & vbCrLf Next objExcel.cells(i,1).value = OrgProcess.GetProp("Organizational Process Code") objExcel.cells(i,2).value = OrgProcess.GetProp("ShortName") objExcel.cells(i,3).value = ObjectivesString i = i + 1 Else objExcel.cells(i,1).value = OrgProcess.GetProp("Organizational Process Code") objExcel.cells(i,2).value = OrgProcess.GetProp("ShortName") i = i + 1 End If Next 'objWorkbook.SaveAs(strFileName) 'objExcel.Quit MsgBox("The Objective report Generation is finished, click Ok to show the report") objExcel.Visible = True End Function '----------------------------------------------------------------------------- ' FUNCTION : InvokeOnRoot ' Function called when the command is triggered from a mgRoot. ' Example : click on a menu. ' ' @param mgRoot ' mgRoot on which the command is applied. '----------------------------------------------------------------------------- Function InvokeOnRoot(mgRoot as MegaObject, sUserData As Variant) End Function