.TXT 파일의 텍스트를 사용하려면 열기 ... 입력 방법을 사용할 수 있습니다. 해당 .TXT 파일의 단어와 줄을 반복하고 문서에서 찾기/바꾸기를 수행 할 수 있습니다. 단어의 당신의 .TXT 목록에 공백이 포함되지 않은 삭제하면 이전 또는 단어 이후에 당신이 떠나 끝날 것
Sub DeleteWordsStoredInTXTFileFromThisDoc()
Dim filePath As String
' change the filePath to point to your file
' you can put the full path, for example "C:\foldername\filename.txt"
filePath = Environ("USERPROFILE") & "\Desktop\textfile.txt"
Open filePath For Input As 1
Dim LineFromFile As String
Do Until EOF(1)
Line Input #1, LineFromFile
Dim LineItems() As String
Dim LineItem As Variant
' depending on how you are listing your naughty words you need to pick from the following lines
' if your words are separated by commas
'LineItems = Split(LineFromFile, ",")
' if your words are separated onto different lines
LineItems = Split(LineFromFile, Chr(13))
For Each LineItem In LineItems
With Selection.Find
.Text = LineItem
.Replacement.Text = ""
.Execute MatchWholeWord:=True, Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
Next LineItem
Loop
Close #1
End Sub
은 유의하시기 바랍니다 : 여기에
는 코드가 당신이 적응할 수 싹둑입니다 문서에서 여분의 공간 뒤에. 당신은 아마 할 때
"Big wolf"
을 얻을 것 "큰 나쁜 늑대"에서 "나쁜"단어를 삭제 "나쁜"또는 "나쁜"이를 방지 도움이 될 것처럼 단어 목록에 공간을 추가
"Big wolf"
. 문서를 교정해야합니다.
감사합니다. Lucas! VBA는 챔피언처럼 일했습니다. 도움에 감사드립니다. --dave – user1704475