Calc Macros: Multiple Optional Parameters [closed]
Hi,
i want to use a Sub with multiple optional paramters in LibreOffice Calc like this:
Sub test(_
ByRef mandatory As String, _
Optional ByRef optional1 As String, _
Optional ByRef optional2 As String)
If IsMissing(optional1) Then
msgbox "Optional Argument 1 Is missing"
Else
msgbox "Optional Argument 1 is: " & optional1
End If
End Sub
Now i want to call this Sub while not using the first optional paramter "optional1"
test("abc",,"def")
To my suprise IsMissing(optional) does not detect that "optional1" is missing. Instead the macro acts like "optional1" is existing and gives me the message box telling me "Optional Argument 1 is: Error |".
How do i handle subs with multiple optional paramters?
Just to understand a bit better: In what way is that a Calc macro? Did you probably pass the parameters via a custom function called from a Calc sheetcell? If so, the issue might be related to bug tdf#102381. (I did not yet test with your code, and don't know of that problem from my experiences when calling sub purely from within BASIC.).)