bbrimberry
New Member
- Joined
- Mar 23, 2016
- Messages
- 34
Hello,
the code below works beautifully but how can I adjust it when I have more columns of data?
I assume I need to adjust the offset line?
Say I had a phone number or address?
thanks in advance!
the code below works beautifully but how can I adjust it when I have more columns of data?
I assume I need to adjust the offset line?
Say I had a phone number or address?
thanks in advance!
VBA Code:
Option Explicit
Dim pp As PowerPoint.Application, ppPres As PowerPoint.Presentation, ppSlide As PowerPoint.Slide, ppShape As PowerPoint.Shape
Sub NewPresentation()
'worksheet range
Dim ws As Worksheet, Cel As Range
Set ws = Sheets("Sheet1")
'create presentation
Set pp = New PowerPoint.Application
Set ppPres = pp.Presentations.Add
pp.Visible = True 'msoTrue
'add slides
For Each Cel In ws.Range("A2", ws.Range("A" & Rows.Count).End(xlUp))
Call AddASlide(Cel, Cel.Offset(, 1), Cel.Offset(, 2))
Next
End Sub
Private Sub AddASlide(Person As Range, Story As Range, PathToPic As Range)
On Error Resume Next
'create the slide
ppPres.Slides.Add ppPres.Slides.Count + 1, ppLayoutBlank
Set ppSlide = ppPres.Slides(ppPres.Slides.Count)
'add namebox & text
Set ppShape = ppSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=100, Top:=50, Width:=200, Height:=50)
ppShape.TextFrame.TextRange.Text = Person
ppShape.TextFrame.TextRange.Font.Size = 30
ppShape.TextFrame.TextRange.Font.Bold = True
'add storybox & text
Set ppShape = ppSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=600, Top:=100, Width:=200, Height:=50)
ppShape.TextFrame.TextRange.Text = Story
'insert picture
ppSlide.Shapes.AddPicture Filename:=PathToPic, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=100, Top:=150, Width:=200, Height:=300
End Sub