This way, we can reuse it in both processes.
CHAPTER 8 n OFFICE INTEGRATION 289
The Helper Functions
We are going to add three separate text entries for our report:
Title text: The title of the report
Title body text: A description or introduction to the report
Subject body text: Brief descriptions for each product chart
For this, we will create three helper functions.
1. In the VBE, add a new standard code module.
2. On the new code module, add the function shown in Listing 8-1 to return the report
title:
Listing 8-1. GetTitle Function
Function GetTitle() As String
GetTitle = "2007 Sales Report"
End Function
3. Below GetTitle, add a function to return the title body text, as shown in Listing 8-2.
Listing 8-2. GetTitleBody Function
Function GetTitleBody() As String
Dim sBody As String
sBody = "Sales for the first four months of 2007 were generally stable. "
sBody = sBody & "Although Baked Goods & Mixes were somewhat flat "
sBody = sBody & "Beverages and Candy showed improvement."
GetTitleBody = sBody
End Function
4. On the same code module, add the function shown in Listing 8-3 to return the subject
body text.
Listing 8-3. GetSubjectBody Function
Function GetSubjectBody(Index As Integer) As String
Dim sBody As String
Select Case Index
Case 1
sBody = "Sales in this category were average " ??
& "for the first third of the year."
Case 2
sBody = "Sales in this category were slightly above average " ??
& "for the first third of the year. February was " ??
& "very good for the season.
Pages:
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272