Search code examples
excelvbaopenxmlribbon

How to make an argument optional?


In a code Module (named ribbon)

Sub Form1Show(control As IRibbonControl)  ' this is custom ribbon
    Form1.Show  ' works
End Sub

In ThisWorkbook module:

Private Sub Workbook_Open()
    Call Form1.Show  '  error: argument not optional
End Sub

Can somebody explain this?


Solution

  • Declare the parameter as optional; otherwise, it is required.

    Sub Form1Show(Optional control As IRibbonControl)