So, das konnte ich als Antwort einfügen. Wollte auch das Dokument mit den Feldfunktionen einfügen, was jedoch nicht gelingt. Gleiches gilt für den kleinen Bildschirmausdruck, den ich in die 2. doc-Datei reinkopiert hatte.
So kann ich nur sagen, dass im Dokument z.B. hinter Vorname in geschweifter Klammer
HTMLCONTROL Forms.HTML:Text.1 steht. Gleiches gilt für Name etc.
Sub DL2()
'
' DL2 Makro
' Makro aufgezeichnet am 06.08.2012 von v172762
' Bookmark "Anfang" am Anfang des Dok. gesetzt, damit Box "Ende Dokument erreicht" abgefangen wird.
Selection.GoTo What:=wdGoToBookmark, Name:="Anfang"
Selection.Find.ClearFormatting
'Suchen nach "VNAnrede (einmalig im Dok. vorhandenens Wort)
With Selection.Find
.Text = "VNAnrede"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.ClearFormatting
With Selection.Find
.Text = "VNAnrede"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'Da im gesamten Dok. der Text Name oder Vorname mehrfach existiert, aber im Bereich VNAnrede nur einmal, erst Bereich anspringen
'mittels Tastatursteuerung, Cursor hinter Vorname platzieren und in HTML-Box springen, dort Kopieren
'und dem Bookmark VNVorname zuweisen.
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="VNVorname"
.DefaultSorting = wdSortByName
.ShowHidden = False
Selection.GoTo What:=wdGoToBookmark, Name:="VNVorname"
Selection.Find.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.Copy
'Zuweisen des Bookmark VNVorname der Variablen "strTempB" als String zur späteren Verarbeitung als Dateiname
'hier späterer Code zur Speicherung
'strDocName = strDocName & " " & strTempC & strTemp & " " & strTempA & ", " & strTempB & ".doc"
'ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
'Selection.HomeKey Unit:=wdStory
Hier kommt es zu der Fehlermeldung, Inhalt von strTempB wird mit einem Quadrat beim überfahren der Variablen mit dem Cursor wiedergegeben.
Dim strTempB As String
strTempB = Selection.Text
strTempB = Left(strTempB, Len(strTempB) - 2)
Selection.PasteAndFormat (wdSingleCellText)
End With
Selection.HomeKey Unit:=wdStory
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Anfang"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub