I’ve looked at other questions with “Object variable not set” and not found an answer.
My code:
Sub TestDaysBefore
Dim settlement As Date
Dim maturity As Date
Dim days As Integer
settlement = InputBox("Enter the settlement date (YYYY-MM-DD):", "Settlement Date")
    If Not IsDate(settlement) Then
        MsgBox "Invalid settlement date entered.", 16, "Error"
        Exit Sub
    End If
 maturity = InputBox("Enter the maturity date (YYYY-MM-DD):", "Maturity Date")
    If Not IsDate(maturity) Then
        MsgBox "Invalid maturity date entered.", 16, "Error"
        Exit Sub
    End If
    
    Dim oService as Object
   oService = CreateUnoService("com.sun.star.sheet.addin.Analysis")
   days = oService.getCoupdaybs(settlement, maturity,2) 'THIS LINE GENERATES THE ERROR
   MsgBox(days)
   
End Sub
I get the error “BASIC runtime error. Object variable not set”.
Would appreciate help.