Code to rerun an operation in the event of an error
Posted on 2007-08-10
In my code I have an operation that consistantly faily, but if I go in debug mode and just hit F8 again to rerun it, it works fine. I am new to programming and am looking for a way that I can have this operation retry (up to 5 times) before it throws an exception. The error is the last line of the code posted below where I pass the prompt value to the business objects report.
Dim BusObjApp As New busobj.Application
BusObjApp.LoginAs("jhaft", "jhaft", False)
Dim BusObjDoc As New busobj.Document
Dim promptName As String = ""
Dim promptValue As String = ""
Dim promptName2 As String = ""
Dim promptValue2 As String = ""
Dim PriorBusinessDayShort As String = ""
Dim PriorBusinessDayLong As String = ""
Dim LasyYearBusinessDayLong As String = ""
PriorBusinessDayShort = "8/9/07"
PriorBusinessDayLong = "8/9/2007"
LasyYearBusinessDayLong = "8/10/2006"
BusObjApp.Interactive = True
BusObjApp.Visible = True
BusObjDoc = BusObjApp.Documents.Open("M:\Corporate\Finance\Corporate Finance\Daily Reporting\NIFO\Daily NIFO Reports\Selected Styles Daily Sales Report Final.Rep", NoAutomaticRefresh:=True)
promptName = "prior business date"
promptValue = PriorBusinessDayLong
BusObjApp.Variables.Item(promptName).Value = promptValue.ToString