R
Rob
Hello all,
After much pain, I figured out how to open Powerpoint from MS
Access
and populate an existing PPoint Table with data from a n Access. The
reason I am not creating the table on the fly is I wanted specific
formatting, so it seemed easier to just create the table on the slide.
Once I played with the PPT presentation, something changed in the
shapes collection and it no longer pointed to the (TABLE) shape.
I had to chage the line:
Slide1.Shapes(1).Select
to
Slide1.Shapes(2).Select
I have no idea why my table is now Shapes(2) !!
All of my heading and slide formatting is in the SLIDE MASTER. The
only object on the Slide is the Table.
Using VBA, how can I retrieve the reference to a (TABLE) shape, so I
always point to the correct Shape?
BTW - I'm using MS Office 2003
Here's my code (be warned -- it's crude; I'm still experimenting)
Option Compare Database
Sub Create_PowerPoint_Slides()
Dim PPT As Object
Dim Pres As PowerPoint.Presentation
Dim Slide1 As PowerPoint.Slide
Set PPT = CreateObject("powerpoint.application")
PPT.Visible = True 'Makes PowerPoint visible
Set Pres = PPT.Presentations.Open( _
FileName:="C:\Documents and Settings\Rob\Desktop\Evaluations
Template.ppt", ReadOnly:=msoFalse)
If Pres.Application.Version >= 9 Then
Pres.Application.Visible = msoTrue 'window must be
visible
End If
Set Slide1 = Pres.Application.ActivePresentation.Slides(1)
Slide1.Shapes(2).Select
Dim Cell_Row, Cell_Column As Integer
Dim Cell_Value As String
Set db = CurrentDb
Dim rs As DAO.Recordset
Dim x As Long
Set rs = CurrentDb.OpenRecordset("SELECT * FROM
[qryInHouse_Reports]", dbOpenDynaset)
Dim vMyRecords() As Variant
rs.MoveLast
x = rs.RecordCount
rs.MoveFirst
vMyRecords() = rs.GetRows(x)
For intRow = 0 To (x - 1)
For intColumn = 1 To 6
Cell_Row = (intRow + 2)
Cell_Column = (intColumn)
Cell_Value = vMyRecords(intColumn, intRow)
Slide1.Application.ActiveWindow.Selection.ShapeRange.Table.Cell(Cell_Row,
Cell_Column).Shape.TextFrame.TextRange.Text = Cell_Value
Next intColumn
Next intRow
End Sub
Rob
After much pain, I figured out how to open Powerpoint from MS
Access
and populate an existing PPoint Table with data from a n Access. The
reason I am not creating the table on the fly is I wanted specific
formatting, so it seemed easier to just create the table on the slide.
Once I played with the PPT presentation, something changed in the
shapes collection and it no longer pointed to the (TABLE) shape.
I had to chage the line:
Slide1.Shapes(1).Select
to
Slide1.Shapes(2).Select
I have no idea why my table is now Shapes(2) !!
All of my heading and slide formatting is in the SLIDE MASTER. The
only object on the Slide is the Table.
Using VBA, how can I retrieve the reference to a (TABLE) shape, so I
always point to the correct Shape?
BTW - I'm using MS Office 2003
Here's my code (be warned -- it's crude; I'm still experimenting)
Option Compare Database
Sub Create_PowerPoint_Slides()
Dim PPT As Object
Dim Pres As PowerPoint.Presentation
Dim Slide1 As PowerPoint.Slide
Set PPT = CreateObject("powerpoint.application")
PPT.Visible = True 'Makes PowerPoint visible
Set Pres = PPT.Presentations.Open( _
FileName:="C:\Documents and Settings\Rob\Desktop\Evaluations
Template.ppt", ReadOnly:=msoFalse)
If Pres.Application.Version >= 9 Then
Pres.Application.Visible = msoTrue 'window must be
visible
End If
Set Slide1 = Pres.Application.ActivePresentation.Slides(1)
Slide1.Shapes(2).Select
Dim Cell_Row, Cell_Column As Integer
Dim Cell_Value As String
Set db = CurrentDb
Dim rs As DAO.Recordset
Dim x As Long
Set rs = CurrentDb.OpenRecordset("SELECT * FROM
[qryInHouse_Reports]", dbOpenDynaset)
Dim vMyRecords() As Variant
rs.MoveLast
x = rs.RecordCount
rs.MoveFirst
vMyRecords() = rs.GetRows(x)
For intRow = 0 To (x - 1)
For intColumn = 1 To 6
Cell_Row = (intRow + 2)
Cell_Column = (intColumn)
Cell_Value = vMyRecords(intColumn, intRow)
Slide1.Application.ActiveWindow.Selection.ShapeRange.Table.Cell(Cell_Row,
Cell_Column).Shape.TextFrame.TextRange.Text = Cell_Value
Next intColumn
Next intRow
End Sub
Rob