我希望这个特定的代码可以在文件夹中的多个PPT文件上运行。但是,如果它打开Powerpoint文件,运行下面的代码,保存并打开下一个代码会更好。欢迎任何建议!我已经通过这个网站上的代码,但似乎无法使它适应我的代码如下(如这一个Loop through files in a folder using VBA?)如何将此VBA应用于文件夹中的多个PPT文件
环不未遂
标志
Sub LoopThroughFiles()
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("c:\testfolder\")
While (file <> "")
If InStr(file, "test") > 0 Then
MsgBox "found " & file
Exit Sub
End If
file = Dir
Wend
End Sub
现有代码
Option Explicit
' Selects the shape that support text which is closest to the top of the slide
' Written by Jamie Garroch of YOUpresent Ltd (http://youpresent.co.uk)
Sub SelectHigestTextShape()
Dim oSld As Slide
Dim oShp As Shape, oShpTop As Shape
Dim sShpTop As Single
On Error Resume Next
Set oSld = ActiveWindow.View.Slide
If Err Then Exit Sub
On Error GoTo 0
' Set the top to the bottom of the slide
sShpTop = ActivePresentation.PageSetup.SlideHeight
' Check each shape on the slide is positioned above the stored position
' Shapes not supporting text and placeholders are ignored
For Each oShp In oSld.Shapes
If oShp.Top < sShpTop And oShp.HasTextFrame And Not oShp.Type = msoPlaceholder Then
sShpTop = oShp.Top
Set oShpTop = oShp
End If
Next
' Select the topmost shape
If Not oShpTop Is Nothing Then oShpTop.Select msoTrue
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
' Clean up
Set oSld = Nothing
Set oShp = Nothing
Set oShpTop = Nothing
End Sub
你试过什么循环? –
Sub LoopThroughFiles() Dim MyObj As Object,MySource As Object,file As Variant file = Dir(“c:\ testfolder \”) While(file <>“”) If InStr(file,“test”) > 0,则 MSGBOX“发现”和文件 退出小组 结束如果 文件= DIR 蜿蜒 结束小组 我已将此添加到代码,但它删除,因为它没有工作:( – Probs
它看起来像使用文件系统对象,你有没有参考加载?它看起来不正确,没有GetFolder在那里像你从 –