PDA

View Full Version : Getting more than 1 field from access via VBA into a PPT presentation.



Thompyt
03-10-2015, 04:07 PM
I am new to this integration into PPT. I would stick with PDF outputs from Access, alas other organizations want to see it in PPT. I have the Report/Query set up to make the following:

12985

I have started the folling code:


Sub cmdPPT_Click()
Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim sTemplate As String
sTemplate = "C:\Temp\Weekly.potx"

'On Error GoTo err_cmdOLEPowerPoint

Set db = CurrentDb
Set rs = db.OpenRecordset("Weekly Closed", dbOpenDynaset)

Set ppObj = New PowerPoint.Application
Set ppPres = ppObj.Presentations.Open(sTemplate, False, True, True)

With ppPres
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
.Shapes(1).TextFrame.TextRange.Text = "Weekly Closed CR's"
.Shapes(1).TextFrame.TextRange.Characters.Font.Name = "Calibri"
.Shapes(1).TextFrame.TextRange.Characters.Font.Size = 28
While Not rs.EOF
'.Shapes(2).ppAlignLeft
.Shapes(2).TextFrame.TextRange.Text = .Shapes(2).TextFrame.TextRange.Text & CStr(rs.Fields("[Change Requested]").Value) & vbCrLf
'Chr(9) & CStr(rs.Fields("[Change Requested]").Value) & Chr(13) & CStr(rs.Fields("[Status]").Value)) &
'.Shapes(2).TextFrame.TextRange.HorizontalAnchor = msoAnchorLeft
.Shapes(2).TextFrame.TextRange.Characters.Font.Name = "Calibri"
.Shapes(2).TextFrame.TextRange.Characters.Font.Size = 16
rs.MoveNext
Wend
Exit Sub
err_cmdOLEPowerPoint:
MsgBox Err.Number & " " & Err.Description
End With
End With
End Sub

For a start I need 4 basic fields:
CR_No
Change Requested
Status
Level

Level is where it should separate the other 3 fields. Level is a grouping function. I found once on the net where there was a template where there were multiple fields where I would replace the name ppLayout"Title"
Is this sufficient to fill the fields? The updated name or is there more needed?

Thanks