The Rev
Registered User.
- Local time
- Today, 13:10
- Joined
- Jan 15, 2003
- Messages
- 118
Good afternoon,
I am trying to have my Access database open up a Powerpoint presentation template .pptx and replace a value with a value from the database. Currently, on the main slide and a few others in the template, we have a placeholder of "XXXXX" for the company name. That value is already part of the database, so I'd like to replace all instances of XXXXX with the value of Me.Company_Name from my Reports form button. I have the following code so far that lets me choose the template from a location, and it tries to cycle through all of the slides looking for that value, but I keep getting an "Object Required" error where I try to start looping through the slides.
I know it's clunky, but I need this to work and I don't remember how to call the Powerpoint slide and textbox... HELP!!
I am trying to have my Access database open up a Powerpoint presentation template .pptx and replace a value with a value from the database. Currently, on the main slide and a few others in the template, we have a placeholder of "XXXXX" for the company name. That value is already part of the database, so I'd like to replace all instances of XXXXX with the value of Me.Company_Name from my Reports form button. I have the following code so far that lets me choose the template from a location, and it tries to cycle through all of the slides looking for that value, but I keep getting an "Object Required" error where I try to start looping through the slides.
Code:
Const msoFileDialogFilePicker As Long = 3
Dim strSelectedFile As String
Dim AppPPT As Object
Set fdg = Application.FileDialog(msoFileDialogFilePicker)
Set objSFolders = CreateObject("WScript.Shell").SpecialFolders
Path = objSFolders("MyDocuments")
With fdg
.AllowMultiSelect = False
.Filters.Add "File Type", "*.pptx", 1
.InitialFileName = Path
If .Show = -1 Then
For Each strSelectedItem In .SelectedItems
Set AppPPT = CreateObject("PowerPoint.Application")
AppPPT.Visible = True
With AppPPT.Presentations.Open(strSelectedItem)
'Here is where I get the error on the following line
For Each Slide In Presentation.Slides
For Each Shape In pptSlide.Shapes
If Shape.Type = TextFrame Then
TextFrame.TextRange.Text = Replace(TextFrame.TextRange.Text, "XXXXX", "Company Name")
End If
Next
Next
End With
'AppPPT.Quit
Next strSelectedItem
Else
End If
End With
Set fdg = Nothing
Set AppPPT = Nothing
Set objSFolders = Nothing
I know it's clunky, but I need this to work and I don't remember how to call the Powerpoint slide and textbox... HELP!!