Open existing PPT for edit then add Access data (1 Viewer)

bbader123

New member
Local time
Today, 14:47
Joined
Apr 5, 2013
Messages
3
Hello - simply trying to open an existing PowerPoint template and then add Access data to it. I started with microsoft automation vb code which opens a new file and addes data. In the code below I have noted the point where I get stuck and can't seem to add data to the existing file I just opened.

Sub cmdPowerPoint_Click()
Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation

'experiental DIMs for exp. code
Dim ppt As Object
Dim pptfile As String
Dim fd As FileDialog

On Error GoTo err_cmdOLEPowerPoint

' Open up a recordset on the Employees table.
Set db = CurrentDb
Set rs = db.OpenRecordset("TravelSch_DTRI_ABS_Query", dbOpenDynaset)

' Open up an instance of Powerpoint. (original code which works)
'Set ppObj = New PowerPoint.Application
'Set ppPres = ppObj.Presentations.Add


'Open existing PowerPoint for edit (this code opens my existing file fine)
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.Show
pptfile = .SelectedItems(1)
End With
Set ppt = CreateObject("PowerPoint.Application")
With ppt
.Visible = True
.Presentations.Open (pptfile)
End With
Set PPPres = ppt.Presentations.Add 'need something different here so added text goes into open file


I need PPRres to write data to open file, not new file. :banghead:

' Setup the set of slides and populate them with data from the
' set of records.
With PPPres
While Not rs.EOF
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
.Shapes(1).TextFrame.TextRange.Text = "Hi! Page " & rs.AbsolutePosition + 1
.SlideShowTransition.EntryEffect = ppEffectFade
With .Shapes(2).TextFrame.TextRange
.Text = CStr(rs.Fields("ProgramOrMissionName").Value)
.Characters.Font.Color.RGB = RGB(255, 0, 255)
.Characters.Font.Shadow = True
End With
.Shapes(1).TextFrame.TextRange.Characters.Font.Size = 50
End With
rs.MoveNext
Wend
End With

' Run the show.
PPPres.SlideShowSettings.Run
Exit Sub

err_cmdOLEPowerPoint:
MsgBox Err.Number & " " & Err.Description



End Sub
 

bbader123

New member
Local time
Today, 14:47
Joined
Apr 5, 2013
Messages
3
So figured it out. I setup a means to prompt user for template file "pptfile" and then used the ".ApplyTemplate" to set the background of the new PowerPoint file being created. Not sure how to close this thread but can be closed.;)

.ApplyTemplate (pptfile) 'apply powerpoint template file selected by user
 

Users who are viewing this thread

Top Bottom