I\'m writing an Excel macro in VBA to send emails to library patrons alerting them of overdue materials. The data comes from a spreadsheet with data like
Use
There's a couple of options.
The easiest is just to make book_list a Variant type. You can treat it as an array using ReDim. You can use variables of Variant type to store object references just like you would with an object variable.
The other option is to make book_list a private variable and create accessor methods. This is the preferred way to use classes anyway, and if you're using classes in the first place, you might as well observe good object oriented design. Your class would look something like this.
Private email_text As String
...
Private book_list() As Book
Private Sub Class_Initialize()
email_text = "default email text"
...
ReDim book_list(10)
End Sub
Public Function GetBook(index As Long) As Book
Set GetBook = book_list(index)
End Function
Public Sub SetBook(index As Long, b As Book)
Set book_list(index) = b
End Sub