Been mucking around with this trying to get it to run. I can't define the size of the array in my first "dim" as it complains that it's already been defined when I ReDim, however an empty bracket set should define a flexible array. There was a comma in MMM's original code, my compiler doesn't like that.
In the sub ExportArrtoExcel, , I don't see why I'm not using the oiPropArr as the argument rather than oArr, which isn't defined. I get an argument type mismatch in the last line of the main sub (renamed ExportProperties,) which leads me to believe my code hasn't generated an array for export. Missing the comma!
So far in my journey into customization I've been fed everything I've needed, and I've read a lot of howtos, but I think I'm going back to basics and visiting the library to get more background on coding.
Sub ExportProperties()
Dim oNextOpenArrRow As Integer
oNextOpenArrRow = 0
Dim oiPropArr() As Object
ReDim Preserve oiPropArr(0 To 2, 0 To 2)
For Each oSubDoc In ThisApplication.ActiveDocument.AllReferencedDocuments
oiPropArr(0, oNextOpenArrRow) = oSubDoc.FullFileName
oiPropArr(1, oNextOpenArrRow) = oSubDoc.PropertySets("Design Tracking Properties")("Part Number").Value
oNextOpenArrRow = oNextOpenArrRow + 1
ReDim Preserve oiPropArr(0 To 2, 0 To oNextOpenArrRow)
Next
ReDim Preserve oiPropArr(0 To 2, 0 To UBound(oiPropArr, 2) - 1)
Call ExportArrToExcel(oiPropArr)
End Sub
Private Sub ShowArray()
'ignore...
'For each "Part Number" in oiPropArr
End Sub
Sub ExportArrToExcel(oArr As Object)
Dim xlApp As Object
Dim xlwb As Object
Dim xlws As Object
xlApp = CreateObject("Excel.Application")
xlwb = xlApp.Workbooks.Add()
xlws = xlwb.Worksheets(1)
xlApp.Visible = True
'For Each arr row...
For iRow = LBound(oArr, 2) To UBound(oArr, 2)
'For each entry
For iColumn = LBound(oArr, 1) To UBound(oArr, 1)
xlws.Cells(iRow + 1, iColumn + 1) = oArr(iColumn, iRow)
Next
Next
xlws = Nothing
xlwb = Nothing
xlApp = Nothing
End Sub