我如何 Select Powerpoint 中的一系列幻灯片 (VBA)
How could i Select a Range of Slides in Powerpoint (VBA)
我编辑了一个 VBa 代码来裁剪活动电源点或特定幻灯片中的所有图片,但是当我想指定一个范围(比如从幻灯片 8 到 40)时,我尝试如下所示:
Sub Auto_pic_crop()
Dim oshp As Shape
Dim osld As Slide
Dim Istart As Integer
Dim Iend As Integer
Istart = ActivePresentation.Slides.Range(Array(8))
Iend = ActivePresentation.Slides.Range(Array(40))
For Each osld In ActivePresentation.Slides
Do While (ActivePresentation.Slides.Range() > Istart) And (ActivePresentation.Slides.Range() < Iend)
For Each oshp In osld.Shapes
If oshp.Type = msoPicture Then
oshp.Width = in2Points(9.77)
oshp.Height = in2Points(4.47)
With oshp.PictureFormat
.Crop.PictureWidth = in2Points(9.69)
.Crop.PictureHeight = in2Points(5.83)
.Crop.ShapeWidth = in2Points(9.64)
.Crop.ShapeHeight = in2Points(4.49)
.Crop.ShapeLeft = in2Points(0.2)
.Crop.ShapeTop = in2Points(0.77)
.Crop.PictureOffsetX = in2Points(0)
.Crop.PictureOffsetY = in2Points(-0.12)
End With
End If
If oshp.Type = msoPlaceholder Then
If oshp.PlaceholderFormat.ContainedType = msoPicture Then
End If
End If
Next oshp
Loop
Next osld
End Sub
Function in2Points(inVal As Single) As Single
in2Points = inVal * 72
End Function
我在编译器上遇到错误。
有没有人可以通过编辑这个或任何其他方式来帮助我?
注意*:我是 VBa 的初学者 :)
我对其进行了一些修改 运行 并试图保持代码的基本框架完整。您可以根据需要进一步开发(修改对象及其属性)。请在键入代码时始终使用自动完成功能。它可以帮助某人坚持任何对象的正确属性或方法。
Sub Auto_pic_crop()
Dim Shp As shape
Dim Sld As Slide
Dim Istart As Integer
Dim Iend As Integer
'Istart = ActivePresentation.Slides.Range(Array(8))
'Iend = ActivePresentation.Slides.Range(Array(40))
'Simply loop through slode nos I could not Understand Range(Array()) part
Istart = 2 'change according to yuor need
Iend = 4 'change according to yuor need
For X = Istart To Iend
Set Sld = ActivePresentation.Slides(X)
For Each Shp In Sld.Shapes
If Shp.Type = msoPicture Then
'Shp.Width = in2Points(9.77)
'Shp.Height = in2Points(4.47)
With Shp.PictureFormat
' I could only think about four type of crop property and
.CropLeft = in2Points(0.2)
.CropTop = in2Points(0.77)
.CropRight = in2Points(0.2)
.CropBottom = in2Points(0.2)
End With
End If
'No action found attached to the Code below
If Shp.Type = msoPlaceholder Then
If Shp.PlaceholderFormat.ContainedType = msoPicture Then
End If
End If
Next Shp
Next X
End Sub
Function in2Points(inVal As Single) As Single
in2Points = inVal * 72
End Function
我编辑了一个 VBa 代码来裁剪活动电源点或特定幻灯片中的所有图片,但是当我想指定一个范围(比如从幻灯片 8 到 40)时,我尝试如下所示:
Sub Auto_pic_crop()
Dim oshp As Shape
Dim osld As Slide
Dim Istart As Integer
Dim Iend As Integer
Istart = ActivePresentation.Slides.Range(Array(8))
Iend = ActivePresentation.Slides.Range(Array(40))
For Each osld In ActivePresentation.Slides
Do While (ActivePresentation.Slides.Range() > Istart) And (ActivePresentation.Slides.Range() < Iend)
For Each oshp In osld.Shapes
If oshp.Type = msoPicture Then
oshp.Width = in2Points(9.77)
oshp.Height = in2Points(4.47)
With oshp.PictureFormat
.Crop.PictureWidth = in2Points(9.69)
.Crop.PictureHeight = in2Points(5.83)
.Crop.ShapeWidth = in2Points(9.64)
.Crop.ShapeHeight = in2Points(4.49)
.Crop.ShapeLeft = in2Points(0.2)
.Crop.ShapeTop = in2Points(0.77)
.Crop.PictureOffsetX = in2Points(0)
.Crop.PictureOffsetY = in2Points(-0.12)
End With
End If
If oshp.Type = msoPlaceholder Then
If oshp.PlaceholderFormat.ContainedType = msoPicture Then
End If
End If
Next oshp
Loop
Next osld
End Sub
Function in2Points(inVal As Single) As Single
in2Points = inVal * 72
End Function
我在编译器上遇到错误。 有没有人可以通过编辑这个或任何其他方式来帮助我? 注意*:我是 VBa 的初学者 :)
我对其进行了一些修改 运行 并试图保持代码的基本框架完整。您可以根据需要进一步开发(修改对象及其属性)。请在键入代码时始终使用自动完成功能。它可以帮助某人坚持任何对象的正确属性或方法。
Sub Auto_pic_crop()
Dim Shp As shape
Dim Sld As Slide
Dim Istart As Integer
Dim Iend As Integer
'Istart = ActivePresentation.Slides.Range(Array(8))
'Iend = ActivePresentation.Slides.Range(Array(40))
'Simply loop through slode nos I could not Understand Range(Array()) part
Istart = 2 'change according to yuor need
Iend = 4 'change according to yuor need
For X = Istart To Iend
Set Sld = ActivePresentation.Slides(X)
For Each Shp In Sld.Shapes
If Shp.Type = msoPicture Then
'Shp.Width = in2Points(9.77)
'Shp.Height = in2Points(4.47)
With Shp.PictureFormat
' I could only think about four type of crop property and
.CropLeft = in2Points(0.2)
.CropTop = in2Points(0.77)
.CropRight = in2Points(0.2)
.CropBottom = in2Points(0.2)
End With
End If
'No action found attached to the Code below
If Shp.Type = msoPlaceholder Then
If Shp.PlaceholderFormat.ContainedType = msoPicture Then
End If
End If
Next Shp
Next X
End Sub
Function in2Points(inVal As Single) As Single
in2Points = inVal * 72
End Function