Hi, I am using Excel and PowerPoint 2007 and have written VBA code in Excel to populate a textbox (TextBox1) on a PowerPoint slide.
For a number of reasons I don't want to create a link between the PPT textbox and an Excel cell. I just want to take the value in the Excel cell and place it into the PPT textbox.
The first thing I do is open the PPT file and duplicate the first slide. The duplicate method was replicating the slide, but was causing other issues, so I got some coding tips to change they way I copy the main slide. Below is the code I have written, which will not compile for the moment.
Any advice would be helpful. Please let me know if you need additional info and thanks!
Sub createppt()
Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim newslide As PowerPoint.Slide
Dim slideCtr As Integer
Dim tb As PowerPoint.Shape
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
Set pres = PPT.Presentations.Open("C:\Documents\createqchart.pptx")
Range("F2").Activate
slideCtr = 1
'Set newslide = ActivePresentation.Slides(slideCtr).Duplicate
Set tb = newslide.Shapes("TextBox1")
pres.Slides(slideCtr).Copy
pres.Slides.Paste
Set newslide = pres.Slides(pres.Slides.Count)
newslide.MoveTo slideCtr + 1
slideCtr = slideCtr + 1
' Do Until ActiveCell.Value = ""
Do Until slideCtr > 2
If slideCtr = 2 Then
tb.Slides.TextFrame2.TextRange.Characters.Text = ActiveCell.Value
End If
ActiveCell.Offset(0, 1).Activate
slideCtr = slideCtr + 1
If slideCtr = 38 Then
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
ActiveCell.Offset(1, -25).Activate
End If
Loop
End Sub
For a number of reasons I don't want to create a link between the PPT textbox and an Excel cell. I just want to take the value in the Excel cell and place it into the PPT textbox.
The first thing I do is open the PPT file and duplicate the first slide. The duplicate method was replicating the slide, but was causing other issues, so I got some coding tips to change they way I copy the main slide. Below is the code I have written, which will not compile for the moment.
Any advice would be helpful. Please let me know if you need additional info and thanks!
Sub createppt()
Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim newslide As PowerPoint.Slide
Dim slideCtr As Integer
Dim tb As PowerPoint.Shape
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
Set pres = PPT.Presentations.Open("C:\Documents\createqchart.pptx")
Range("F2").Activate
slideCtr = 1
'Set newslide = ActivePresentation.Slides(slideCtr).Duplicate
Set tb = newslide.Shapes("TextBox1")
pres.Slides(slideCtr).Copy
pres.Slides.Paste
Set newslide = pres.Slides(pres.Slides.Count)
newslide.MoveTo slideCtr + 1
slideCtr = slideCtr + 1
' Do Until ActiveCell.Value = ""
Do Until slideCtr > 2
If slideCtr = 2 Then
tb.Slides.TextFrame2.TextRange.Characters.Text = ActiveCell.Value
End If
ActiveCell.Offset(0, 1).Activate
slideCtr = slideCtr + 1
If slideCtr = 38 Then
Set newslide = PPT.ActivePresentation.Slides(slideCtr).Duplicate
ActiveCell.Offset(1, -25).Activate
End If
Loop
End Sub