List the contents of a directory: gets "children" of given directory, formats results as a table, and pastes into the worksheet (with header row by default) at the specified location.


Public Function ListDir(dir As String, destination As String, _ 
                        fields As String, _ 
                        Optional getType As String = "both", _ 
                        Optional quiet As Boolean = False, _ 
                        Optional noHeaders as Boolean = False, _ 
                        Optional descendants as Boolean = False) As Integer


 dirFull path of directory for which contents will be listed.
 destinationRange (named or address) of top left cell where results should be pasted.
 fieldsComma-delimited list of table or directory attributes to retrieve (can be table or directory attributes; irrelevant attributes are ignored; a column will be created in the output table for each field specified). Available fields (attributes) for tables and directories can be found in the 1010data API documentation for the gettab and getdir transactions respectively. An additional field entrytype indicating dir or tab is also available.
 getType(optional) Can be dir, tab, or both. Defaults to both.
 quiet(optional) Set to true to suppress output to user in case of error. Defaults to false.
 noHeaders(optional) Set to true to return output without a header row listing the fields retrieved. Defaults to false (headers appear by default).
 descendants(optional) Set to true to include subdirectories and their contents. Defaults to false (only the specified directory).

Return value

 -1fatal error (further attempts are likely to fail, connectivity problem or the like)


Example usage:
result = a1010data.ListDir("", "sheet1!$A$1", "id,name,title,rows")

The above will generate the table below and paste it to sheet1!$A$1:

id name title rows
37429 Players 15350
37433 Batting 78881
37434 Pitching 32896
37435 Fielding 59884
37436 All-Star Teams 3707
37437 Hall of Fame 239
37438 Managers 2895
37439 Teams 2327
37440 Awards 1346
37441 Post-Season Batting 7439
37442 Post-Season Pitching 2776