開いている Word ドキュメントを検索し、ドキュメントのすべての領域 (StoryRanges) 内で検索と置換を実行する以下のコードに出くわしました。正常に動作しますが、開いているアクティブなドキュメントだけでなく、選択したフォルダー内のすべてのドキュメントを参照し、そのフォルダー内のすべてのドキュメントを検索して置換するようにこのコードを変更する方法を教えてください。
私の計画は、マクロを Excel のボタンに割り当てて、ユーザーがそれをクリックしてフォルダーに移動し、多数のドキュメントを一度に検索して置換できるようにすることです。
「IN ActiveDocument.StoryRanges」セクションを修正して、代わりにフォルダーを参照することはできますか? 私はそれを何に修正できるかわかりません。ところで...私はvbaを初めて使用し、調査と学習を試みています...私がそれで私の足を見つけようとしている間、あなたの時間、忍耐、そしてあなたが与えることができる助けに感謝します-アレックス。
範囲として myStoryRange を薄暗くする
For Each myStoryRange In ActiveDocument.StoryRanges
With myStoryRange.Find
.Text = "Text to find to replace goes here"
.Replacement.Text = "And the replacement text goes here"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Do While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
With myStoryRange.Find
.Text = "Text to find to replace goes here"
.Replacement.Text = "And the replacement text goes here"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Loop
Next myStoryRange