Листинг 3
Public poBase As Collection ' коллекция: таблицы + поля
Public Sub BaseCollectionSet()
'-- Обход книги и создание коллекции таблиц
Dim oFields As Collection ' коллекция полей
Dim sTableName As String ' имя таблицы
Dim oSheet As Worksheet ' текущая Worksheet
Dim oTable As Table ' дескриптор таблицы
Dim sPrimKey As String ' имя первичного ключа
Set poBase = New Collection
For Each oSheet In ActiveWorkbook.Worksheets
If LCase(Right(oSheet.Name, 5)) = "_prop" Then
sPrimKey = ""
Set oFields = New Collection
sTableName = FieldsCollectionSet(oSheet, _
oFields, sPrimKey)
Set oTable = New Table
oTable.Name = sTableName
Set oTable.Fields = oFields
If sPrimKey <> "" Then oTable.Key = sPrimKey
poBase.Add oTable, oTable.Name
End If
Next
End Sub