2016-09-29 6 views
0

以下特定の単語を見つけて置き換えるコードがあります。しかし、私のVBA知識は限られているので、このコードをフォルダ内の複数のPowerpointファイルにループさせて保存する方法がわかりません。また、それは最初のシートに書かれた言葉だけを取ります、私はそれが何であるか分かりません。複数のファイルをループするVBA

Sub DemoFindReplace() 
Dim sld As Slide 
Set sld = ActivePresentation.Slides(1) 
Dim shp As Shape 
For Each shp In sld.Shapes 
If shp.HasTextFrame Then 
    If shp.TextFrame.HasText Then 
     shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "TEST", "REPLACE") 
    End If 
End If 
Next shp 
End Sub 
+0

に注意してください。フォント、太字などに内部的な違いがない限り、コードはすべてのテキストボックスの書式設定を破ることになります。 – Jbjstam

答えて

0

それは本当にあなたが求めている明確で研ぐありませんが、あなたはファイルの数をループにしたい場合は、以下のコードが役立ちます:

Dim MyFile, MyPath, MyName As String 
' Returns "WIN.INI" if it exists. 
MyFile = Dir("C:\WINDOWS\WIN.INI") 

' Returns filename with specified extension. If more than one *.INI 
' file exists, the first file found is returned. 
MyFile = Dir("C:\WINDOWS\*.INI") 

' Call Dir again without arguments to return the next *.INI file in the 
' same directory. 
MyFile = Dir() 

' Return first *.TXT file, including files with a set hidden attribute. 
MyFile = Dir("*.TXT", vbHidden) 

' Display the names in C:\ that represent directories. 
MyPath = "c:\" ' Set the path. 
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry. 
Do While MyName <> "" ' Start the loop. 
     ' Use bitwise comparison to make sure MyName is a directory. 
     If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then 
     ' Display entry only if it's a directory. 
     MsgBox(MyName) 
     End If 
    MyName = Dir() ' Get next entry. 
Loop 

出典:https://msdn.microsoft.com/en-us/library/dk008ty4(v=vs.90).aspx

関連する問題