RockMechMark
09-20-2011, 05:05 PM
I requested help with a first project at reformatting the size and position of four objects (all were jpg) on a slide. I appreciate the help. The following code works for another case where there are two objects on a slide. First I size them to maximum, then size them to the final size:
Sub FormatSlidePix()
Dim i As Integer
ActiveWindow.Activate
For i = 1 To ActiveWindow.Selection.SlideRange.Shapes.Count
With ActiveWindow.Selection.SlideRange.Shapes(i)
Select Case (i)
Case 1
.LockAspectRatio = msoTrue ' Locks aspect ratio
.Height = 768 ' Aspect ratio based on height of pic in points
.PictureFormat.CropRight = 0
.PictureFormat.CropBottom = 0
.Left = 0
.Top = 0
.Name = "Picture 1"
Case 2
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropRight = 0
.PictureFormat.CropBottom = 0
.Height = 768 ' Aspect ratio based on height of pic in points
.Left = 367
.Top = 0
.Name = "Picture 2"
End Select
End With
With ActiveWindow.Selection.SlideRange.Shapes(i)
Select Case (i)
Case 1
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropLeft = 24
.PictureFormat.CropBottom = 29
.Height = 540 ' Aspect ratio based on height of pic in points
.Left = 0
.Top = 3
.Name = "Picture 1"
Case 2
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropRight = 101
.PictureFormat.CropBottom = 7
.Height = 540 ' Aspect ratio based on height of pic in points
.Left = 367
.Top = 0
.Name = "Picture 2"
End Select
End With
Next i
ActiveWindow.Selection.Unselect
End Sub
Now here is the next addition for which I need help.
I want to incorporate the above, however, there are 132 slides, each with two such objects. For the first slide, I want to replace the first object with a file named EC_MExc_000.jpg and the second object with a slide named EC_Modified_Sequence_closure_000.jpg. Then I want to reformat as in the script above. For the second slide, the replacement filenames are the same, but replace the digits with 001. For the third slide, the replacement digits are 002, until the 132nd slide has replacement digits 131 in the filename (always three digits). I envision a routine that loops through the slides, and at each slide, replaces the objects using a filename root for each object, converts a slide loop counter to one less in number and makes it three digits to append to the root filename with ".jpg" so the correct filename can be identified, then resize and reposition the objects as above.
Because I do not understand the nomenclature very well, I am having an awful time with the help index and search utility.
Thanks.
RockMechMark
Sub FormatSlidePix()
Dim i As Integer
ActiveWindow.Activate
For i = 1 To ActiveWindow.Selection.SlideRange.Shapes.Count
With ActiveWindow.Selection.SlideRange.Shapes(i)
Select Case (i)
Case 1
.LockAspectRatio = msoTrue ' Locks aspect ratio
.Height = 768 ' Aspect ratio based on height of pic in points
.PictureFormat.CropRight = 0
.PictureFormat.CropBottom = 0
.Left = 0
.Top = 0
.Name = "Picture 1"
Case 2
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropRight = 0
.PictureFormat.CropBottom = 0
.Height = 768 ' Aspect ratio based on height of pic in points
.Left = 367
.Top = 0
.Name = "Picture 2"
End Select
End With
With ActiveWindow.Selection.SlideRange.Shapes(i)
Select Case (i)
Case 1
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropLeft = 24
.PictureFormat.CropBottom = 29
.Height = 540 ' Aspect ratio based on height of pic in points
.Left = 0
.Top = 3
.Name = "Picture 1"
Case 2
.LockAspectRatio = msoTrue ' Locks aspect ratio
.PictureFormat.CropRight = 101
.PictureFormat.CropBottom = 7
.Height = 540 ' Aspect ratio based on height of pic in points
.Left = 367
.Top = 0
.Name = "Picture 2"
End Select
End With
Next i
ActiveWindow.Selection.Unselect
End Sub
Now here is the next addition for which I need help.
I want to incorporate the above, however, there are 132 slides, each with two such objects. For the first slide, I want to replace the first object with a file named EC_MExc_000.jpg and the second object with a slide named EC_Modified_Sequence_closure_000.jpg. Then I want to reformat as in the script above. For the second slide, the replacement filenames are the same, but replace the digits with 001. For the third slide, the replacement digits are 002, until the 132nd slide has replacement digits 131 in the filename (always three digits). I envision a routine that loops through the slides, and at each slide, replaces the objects using a filename root for each object, converts a slide loop counter to one less in number and makes it three digits to append to the root filename with ".jpg" so the correct filename can be identified, then resize and reposition the objects as above.
Because I do not understand the nomenclature very well, I am having an awful time with the help index and search utility.
Thanks.
RockMechMark