Variable text in PowerPoint

D

doug

I want to run a macro in Excel, which updates the footer
in PowerPoint, each footer will have two different
variables concatenated into a sentence. The variables will
have the value from Excel cells changing for each slide as
I go through a loop working down a list.

Anybody ever try anything like this?
 
A

Andy Pope

Hi Doug,

Try the code below.
It assumes that the text in column A and B will be used.
If the 2 cells within the current row are blank it stops.

No error checking is there is not enough slides.

Sub PPT_Footers()

Dim lngSlide As Long
Dim strFooter As String
Dim rngX As Range
Dim objApp As PowerPoint.Application
Dim objPPT As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide

Set objApp = CreateObject("PowerPoint.application")
If objApp Is Nothing Then
MsgBox "Unable to open PowerPoint", vbCritical
Exit Sub
End If
objApp.Visible = msoTrue
Set objPPT = objApp.Presentations.Open("D:\Temp\test.ppt")
If objPPT Is Nothing Then
MsgBox "Unable to open PowerPoint file", vbExclamation
Exit Sub
End If
For Each rngX In Range("A:A")
strFooter = rngX.Text & " " & rngX.Offset(0, 1).Text
If Trim(strFooter) = "" Then Exit For
lngSlide = lngSlide + 1
Set objSlide = objPPT.Slides(lngSlide)
objSlide.HeadersFooters.Footer.Text = strFooter
Next
objPPT.Save
objPPT.Close
objApp.Quit

Set objSlide = Nothing
Set objPPT = Nothing
Set objApp = Nothing
End Sub

I want to run a macro in Excel, which updates the footer
in PowerPoint, each footer will have two different
variables concatenated into a sentence. The variables will
have the value from Excel cells changing for each slide as
I go through a loop working down a list.

Anybody ever try anything like this?

--

Cheers
Andy

http://www.andypope.info
 
D

doug

thanks, will try that.
-----Original Message-----
Hi Doug,

Try the code below.
It assumes that the text in column A and B will be used.
If the 2 cells within the current row are blank it stops.

No error checking is there is not enough slides.

Sub PPT_Footers()

Dim lngSlide As Long
Dim strFooter As String
Dim rngX As Range
Dim objApp As PowerPoint.Application
Dim objPPT As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide

Set objApp = CreateObject("PowerPoint.application")
If objApp Is Nothing Then
MsgBox "Unable to open PowerPoint", vbCritical
Exit Sub
End If
objApp.Visible = msoTrue
Set objPPT = objApp.Presentations.Open ("D:\Temp\test.ppt")
If objPPT Is Nothing Then
MsgBox "Unable to open PowerPoint file", vbExclamation
Exit Sub
End If
For Each rngX In Range("A:A")
strFooter = rngX.Text & " " & rngX.Offset(0, 1).Text
If Trim(strFooter) = "" Then Exit For
lngSlide = lngSlide + 1
Set objSlide = objPPT.Slides(lngSlide)
objSlide.HeadersFooters.Footer.Text = strFooter
Next
objPPT.Save
objPPT.Close
objApp.Quit

Set objSlide = Nothing
Set objPPT = Nothing
Set objApp = Nothing
End Sub



--

Cheers
Andy

http://www.andypope.info

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top