franzmann
Goto Top

Suchen und Ersetzen von Werten per Makro

Hallo,
hoffe jemand kann mir helfen...
Ich will folgendes realisieren, hab aber nur bedingt Ahnung von Makros und überhaupt keine Ahnung von Visual Basic !
Ich habe vorhandene Makros die zu Analysezwecken Versionsnummer auslesen sollen.
Jetzt habe ich das Problem das diese Makros sehr viel Quellcode haben und ich die sich ständig ändernden Versionsnummern nicht immer von Hand editieren will.
Würde das gerne nach dem "Suchen & Ersetzen"-Prinzip machen. Von Vorteil wäre hierbei wenn man das ganze auch als Makro in den vohandenen Quellcode implementieren könnte ?
Gibt es da Wege und Lösungen sowas, vielleicht sogar mit Eingabemaske, zu realisieren ?

Hier ein Auszug der Makros. Ist zwar nicht der ganze Code, aber er wiederholt sich eh nur, also belanglos. Die fettmakierten und in " " sind Wert/ Parameter die jedesmal editiert werden sollen:


Sub Anlagen()

ChangeFileOpenDirectory "D:\Anlagen\ABC\uebersicht\l1\H249\1.3\"
Documents.Open FileName:="1.3.ddl", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, Encoding:=1252
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "{"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ",^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ",^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "°"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.SaveAs FileName:="1.3.ddl.txt", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=True, AllowSubstitutions:=False, _
LineEnding:=wdCRLF
ActiveDocument.Close

ChangeFileOpenDirectory "D:\Anlagen\ABC\uebersicht\l1\H300\1.3\"
Documents.Open FileName:="1.3.ddl", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, Encoding:=1252
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "{"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ",^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ",^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "°"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.SaveAs FileName:="1.3.ddl.txt", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=True, AllowSubstitutions:=False, _
LineEnding:=wdCRLF
ActiveDocument.Close


End Sub


Danke schon mal...

Content-Key: 41710

Url: https://administrator.de/contentid/41710

Printed on: April 19, 2024 at 16:04 o'clock

Member: Biber
Biber Oct 09, 2006 at 12:02:11 (UTC)
Goto Top
Moin Franzmann,

wäre es eine Lösung, die "Sub Anlagen()" um zwei Parameter zu erweitern?
Sinngemäß so:
Sub Anlagen( String strDirectory, String strFilename)

Gruß
Biber
Member: Franzmann
Franzmann Oct 09, 2006 at 12:58:38 (UTC)
Goto Top
Hey,
sorry für meine nicht ganz kompetente Frage, aber was bringt mir die Erweiterung ?
Meinst du das ich durch das "einpacken" in Variablen die Werte dann auto. ändern lassen kann ?
So ganz hab ichs noch net verstanden, erläuter mal bitte mehr...!
THX
Franzmann