PDA

View Full Version : Include Section name in filenames of images



PetraL
04-25-2019, 04:51 PM
Hi,

I'd like the filenames of images to include Section name.

This is my code so far:

Sub SaveImagesSection()
Dim oSldSource As Slide
Dim oShpSource As Shape
Dim Ctr As Integer


Dim sPath As String


sPath = "xxx"
Ctr = 1


For Each oSldSource In ActivePresentation.Slides
For Each oShpSource In oSldSource.Shapes

If oShpSource.Type = msoGroup Then

Call oShpSource.Export(sPath & [Section Name here] & Format(Ctr, "00") & ".png", ppShapeFormatPNG)

Ctr = Ctr + 1
End If

Next oShpSource
Next oSldSource




End Sub

Thanks in advance

John Wilson
04-26-2019, 01:09 AM
Try something like this:


Sub SaveImagesSection()
Dim oSldSource As Slide
Dim oShpSource As Shape
Dim Ctr As Integer
Dim secName As String
Dim sPath As String
sPath = "C:/users/info/Desktop/"
Ctr = 1
For Each oSldSource In ActivePresentation.Slides
For Each oShpSource In oSldSource.Shapes


If oShpSource.Type = msoGroup Then
If ActivePresentation.SectionProperties.Count > 0 Then
secName = ActivePresentation.SectionProperties.Name(oSldSource.sectionIndex)
End If
Call oShpSource.Export(sPath & secName & Format(Ctr, "00") & ".png", ppShapeFormatPNG)
Ctr = Ctr + 1
End If
Next oShpSource
Next oSldSource
End Sub

PetraL
04-27-2019, 02:07 AM
Worked a treat. Thank you so much, John.

I forgot the final backslash in the filepath but eventually figured out why nothing was happening.

Regards,
Petra