私は、第三者の注意を引く必要がある冒とく的な表現を時折含む TV スクリプトを持っています。特定の単語を検索し、一時的にそれらを変形して繰り返し検出されないようにし、それらをリストし、それらがマクロ内で出現する時間をリストするマクロを作成しました... 問題: 実行しなくても、単語の最初のインスタンスのみを見つけます...同じ単語を20回言うこともあります...各出現とタイムコードをリストする必要があります。置き換えたり強調表示したりせずに、単語をリストするだけです。私がこれまでに持っているもの...どんな助けも大歓迎です。
Sub Macro7()
'
' Macro7 Macro
'
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "dog"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
' places cursor inside the word so I can disfigure it
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1
' xxx1 temporarily disfigures the word so it isn't re-found over and over
Selection.TypeText Text:="xxx1"
' goes to end of document and pastes the word there,
' to be joined by the matching timecode to be found next
Selection.EndKey Unit:=wdStory
Selection.PasteAndFormat (wdPasteDefault)
Selection.Find.ClearFormatting
' returns to last instance of word and finds time code
' immediately preceeding it
With Selection.Find
.Text = "xxx1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
'this is finding the time code
.Text = "^?^?:^?^?:^?^?:^?^?"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
' copies the time code value and goes to bottom of document
' to paste it with the word previously found
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeText Text:=vbTab
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeParagraph
Selection.Find.ClearFormatting
' returns to the word just found
With Selection.Find
.Text = "xxx1"
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
' begins the process for the next word "cat"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "cat"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
' places cursor inside the word so I can disfigure it
' etc etc etc
End Sub