dcatt
08-26-2014, 07:02 AM
Hello,
I have about 20 PowerPoint files with 100 slides each; the slides contain a picture and a textbox that references the intended filename of the picture.
I want to write a VBA macro that will look at every slide and save the pictures to the PowerPoint filepath folder with a filename extracted from the text in the text box.
I've had trouble with the object export function as well as specifying the difference between the image and the text box. The code below doesn't even address trying to use the text contents of the textbox as a filename. Any help would be greatly appreciated.
David
Sub Picture()
Dim thePresentation As Presentation
Dim theSlides As Slides
Dim curSlide As Slide
Dim curShape As Shape
Dim CurrentPageName As String
Dim CurrentPageNumber As Integer
Dim CurrentFileIndex As Integer
Set thePresentation = ActivePresentation
Set theSlides = thePresentation.Slides
CurrentPageNumber = 0
For Each curSlide In theSlides 'get every single slide
CurrentPageNumber = CurrentPageNumber + 1
' go to each slide
For Each curShape In curSlide.Shapes ' inspect every shape
CurrentFileIndex = 1
If curShape.Type = 13 Then
fname = thePresentation.Path & "\" & "stuff\Page" & CurrentPageNumber & "_" & CurrentFileIndex & ".jpg"
curShape.Export fname, ppShapeFormatJPG
CurrentFileIndex = CurrentFileIndex + 1
End If
Next curShape
Next curSlide
End Sub
I have about 20 PowerPoint files with 100 slides each; the slides contain a picture and a textbox that references the intended filename of the picture.
I want to write a VBA macro that will look at every slide and save the pictures to the PowerPoint filepath folder with a filename extracted from the text in the text box.
I've had trouble with the object export function as well as specifying the difference between the image and the text box. The code below doesn't even address trying to use the text contents of the textbox as a filename. Any help would be greatly appreciated.
David
Sub Picture()
Dim thePresentation As Presentation
Dim theSlides As Slides
Dim curSlide As Slide
Dim curShape As Shape
Dim CurrentPageName As String
Dim CurrentPageNumber As Integer
Dim CurrentFileIndex As Integer
Set thePresentation = ActivePresentation
Set theSlides = thePresentation.Slides
CurrentPageNumber = 0
For Each curSlide In theSlides 'get every single slide
CurrentPageNumber = CurrentPageNumber + 1
' go to each slide
For Each curShape In curSlide.Shapes ' inspect every shape
CurrentFileIndex = 1
If curShape.Type = 13 Then
fname = thePresentation.Path & "\" & "stuff\Page" & CurrentPageNumber & "_" & CurrentFileIndex & ".jpg"
curShape.Export fname, ppShapeFormatJPG
CurrentFileIndex = CurrentFileIndex + 1
End If
Next curShape
Next curSlide
End Sub