Sub
FirmenNamenTauschen(Verz
As
String
, DName
As
String
)
Dim
Kundenname
As
String
On
Error
Resume
Next
Documents.Open (Verz & DName)
Kundenname = Userform1.Kundenkuerzel
If
UserForm3.TextBox1 >
""
Then
Kundenname = UserForm3.TextBox1
Dim
oStory
As
Range
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abc GmbH"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text = abc"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abc GmbH"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abc GmbH"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abc.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abc.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abC.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"abC.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"Boxx"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"Boxx"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"BOXX"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"BOXX"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"boxx"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"boxx"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"BoxX"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"BoxX"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"boxx.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"boxx"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"press.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"press.de"
.Replacement.Text = Kundenname
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
For
Each
oStory
In
ActiveDocument.StoryRanges
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"xxx"
.Replacement.Text =
"Disposition"
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
While
Not
(oStory.NextStoryRange
Is
Nothing
)
Set
oStory = oStory.NextStoryRange
oStory.Find.ClearFormatting
oStory.Find.Replacement.ClearFormatting
With
oStory.Find
.Text =
"Zuglaufsteuerung"
.Replacement.Text =
"Disposition"
.Forward =
True
.Wrap = wdFindContinue
.Format =
False
.MatchCase =
True
.MatchWholeWord =
True
.MatchWildcards =
False
.MatchSoundsLike =
False
.MatchAllWordForms =
False
End
With
oStory.Find.Execute Replace:=wdReplaceAll
Wend
Next
If
Userform1.TextBox1 >
""
Then
Call
Speichern
ActiveDocument.Close
End
If
If
UserForm3.TextBox1 >
""
Then
Call
Speichern
ActiveDocument.Close
End
If
End
Sub