11.07.2015 Views

Automate Scheduler Using Macros

Automate Scheduler Using Macros

Automate Scheduler Using Macros

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: ObjectsApplication ObjectDescriptionAn object providing access to various <strong>Scheduler</strong> collections, methodsand properties, and containing basic information about the OLE serverenvironment.DiscussionYou create an Application object to start <strong>Scheduler</strong> from within an OLEautomation script. Create the <strong>Scheduler</strong> Application object using the Dimcommand to create an object variable and then set it equal to thereference returned by the CreateObject function.ExampleThis example returns a list of all completed tasks, including any witherrors, and displays them in a message box.Sub Main()Dim objSchedApp As ObjectDim objCompletedTasks As ObjectDim objCompletedTask As ObjectDim intCounter As IntegerDim strListOfTasks As StringDim strErrors As StringSet objSchedApp = CreateObject("Cognosbatcher.Application")'get a reference to all tasks that have been completedSet objCompletedTasks = _objSchedApp.Completed strListOfTasks = ""For intCounter = 1 To objCompletedTasks.CountIf objCompletedTasks.Item(intCounter).HasErrors ThenstrErrors = " -> Error"ElsestrErrors = ""End IfSet objCompletedTask = _objCompletedTasks.Item(intCounter).SchedulestrListOfTasks = strListOfTasks & _objCompletedTask.ScheduleDescription strErrors & Chr(13)Next intCounterMsgBox("There are " & Str(objCompletedTasks.Count) & _"completed tasks:" & Chr(13) & strListOfTasks)Set objCompletedTask = NothingSet objCompletedTasks = NothingSet objSchedApp = NothingEnd SubMethod NameVisibleMutuallyExclusiveDescriptionSets the <strong>Scheduler</strong> main window tovisible.Notifies <strong>Scheduler</strong> that Impromptu isbeing automated.10 <strong>Automate</strong> <strong>Scheduler</strong> <strong>Using</strong> <strong>Macros</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!