|
楼主 |
发表于 2016-9-11 19:49
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 weiyingde 于 2016-9-11 20:31 编辑
昨天喝醉了,看了你帖子之后,未加深究,为感受奇妙,遗憾。
今天再把的代码融入的程序之中,不知什么原因,还是没有结果,而且还没你原先的代码来得快。
这段代码的运行平台是ppt。
整个过程如下:
Sub 随机插入视频()
Dim my$, mypaths$, brr()
my = "H:\Ofenused\精选音频\视频\"
i = 1
Erase arr: Ts = ""
Qu my, 0
sj = Int(Rnd * UBound(arr))
ReDim brr(LBound(arr) To UBound(arr))
brr(sj) = Left(arr(sj), Len(arr(sj)) - 1)
For Each shp In ActivePresentation.SlideShowWindow.View.Slide.Shapes
If shp.Type = 16 Then shp.Delete
Next
Set shp = Nothing
Set shps = ActivePresentation.SlideShowWindow.View.Slide.Shapes
With shps.AddMediaObject2(FileName:=brr(sj), Left:=l, Top:=t, Width:=w, Height:=h)
Randomize
.AutoShapeType = Choose(Int(Rnd * 9) + 1, 6, 9, 10, 132, 13, 28, 94, 95, 96)
With .ThreeD
If sj Mod 2 = 1 Then
.SetThreeDFormat msoThreeD & (Int(Rnd * 20) + 1)
Else
.BevelTopType = 3
.BevelTopDepth = 10
.BevelBottomType = 3
.BevelBottomDepth = 6
End If
End With
End With
End Sub
Private Sub Qu(my$, j%)
Dim mypaths$, Mys$
Mys = Dir(my, vbDirectory)
Do While Mys <> ""
If Mys <> "." And Mys <> ".." And Mys <> ActivePresentation.Name Then
j = j + 1
ReDim Preserve arr(1 To j)
arr(j) = my & Mys & "\"
End If
Mys = Dir
Loop
If IsArray(Ts) = False Then Ts = arr: Erase arr: j = 0
If i > UBound(Ts) Then Exit Sub
my = Ts(i)
If my <> "" Then
i = i + 1
Qu my, j
Else
Exit Sub
End If
End Sub
|
|