2016-09-29 3 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