Here's the code:
Set rsRowCount = db.OpenRecordset("...
varRowCount = 1
Do While Not rsRowCount.EOF
i = varRowCount
varRowCount = 1 + i
rsRowCount.MoveNext
Loop
Set objGraph = prsPres.Slides(1).Shapes.AddTable(varRowCount, 4,
ChartWidth + 15, ChartTop + 5, ChartWidth, ChartHeight / 2)
With objGraph.Table
With .Rows(1)
.Height = 7
End With
With .Cell(1, 1).Shape.TextFrame
.TextRange.Text = "Company"
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(1, 2).Shape.TextFrame
.TextRange.Text = "2005-Q1 to 2005-Q4"
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(1, 3).Shape.TextFrame
.TextRange.Text = "2006-Q1 to 2006-Q4"
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(1, 4).Shape.TextFrame
.TextRange.Text = "Share Change"
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
End With
Set rsCompany = db.OpenRecordset("...
varAddRow = 1
Do While Not rsCompany.EOF
i = varAddRow
With objGraph.Table
.Columns(1).Width = 90
With .Rows(i)
.Height = 7
With .Cells.Borders(ppBorderBottom)
.DashStyle = msoLineSolid
.Weight = 1
End With
End With
With .Cell(i + 1, 1).Shape.TextFrame
.TextRange.Text = rsCompany!Company
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(i + 1, 2).Shape.TextFrame
.TextRange.Text =
FormatPercent((rsCompany!PeriodOneDollarsChangePercent), 2)
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(i + 1, 3).Shape.TextFrame
.TextRange.Text =
FormatPercent((rsCompany!PeriodTwoDollarsChangePercent), 2)
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
With .Cell(i + 1, 4).Shape.TextFrame
.TextRange.Text =
FormatPercent((rsCompany!DollarsChangePercent), 2)
.TextRange.Font.Size = 8
.TextRange.Font.Color = 0
.HorizontalAnchor = msoAnchorCenter
.MarginBottom = 0
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
End With
End With
varAddRow = 1 + i
rsCompany.MoveNext
Loop
With objGraph.Table
For m = 2 To 4
.Columns(m).Width = 45
Next
With .Rows(i + 1)
.Height = 7
End With
End With