title: Defining a Literal 2D String Array in VBA
body: <p>I'm trying to construct a utility function to prompt the user for an arbitrary file via the standard Windows file dialog.</p>
  
  <p>I would like to pass the list of filetype filters as a two dimensional array of strings, where the first element of each subarray is the filetype description and the second element is the filetype filter.</p>
  
  <p>Below is my function:</p>
  
  <pre><code>'' GetFile  -  Lee Mac
  ''
  '' Prompts the user to select a file using a standard Windows file dialog
  ''
  '' msg - [str] Dialog title
  '' ini - [str] Initial filename/filepath
  '' flt - [arr] Array of filetype filters
  ''
  Function GetFile(Optional strMsg As String = "Select File", Optional strIni As String = vbNullString, Optional arrFlt) As String
      Dim dia As FileDialog
      Set dia = Application.FileDialog(msoFileDialogFilePicker)
      With dia
          .InitialFileName = strIni
          .AllowMultiSelect = False
          .Title = strMsg
          .Filters.Clear
          If IsMissing(arrFlt) Then
              .Filters.Add "All Files", "*.*"
          Else
              Dim i As Integer
              For i = 0 To UBound(arrFlt, 1)
                  .Filters.Add arrFlt(i, 0), arrFlt(i, 1)
              Next i
          End If
          If .show Then
              GetFile = .selecteditems.Item(1)
          End If
      End With
  End Function
  </code></pre>
  
  <p>This works, however, when supplying the filetype filter argument to the function, I find myself having to do something like this:</p>
  
  <pre><code>Function test()
      Dim arr(1, 1) As String
      arr(0, 0) = "Excel Files"
      arr(0, 1) = "*.xls;*.xlsx"
      arr(1, 0) = "Text Files"
      arr(1, 1) = "*.txt"
  
      GetFile , , arr
  End Function
  </code></pre>
  
  <p>I've also tried the following but receive 'Subscript out of range':</p>
  
  <pre><code>Dim arr() As Variant
  arr = Array(Array("Excel Files", "*.xls;*.xlsx"), Array("Text Files", "*.txt"))
  </code></pre>
  
  <p>Is there a better way to define a literal 2D string array that I'm missing?</p>
  
  <p>Many thanks in advance for your advice &amp; feedback.</p>