Hallo Dorstadt,
mit einem VBA-Modul können Sie in beliebig vielen Word-Dokumenten den Autoren-Namen ändern lassen:
Hierzu muss ein neues Word-Dokument erstellt werden und anschließend im VBA-Editor folgende Objekte eingefügt werden:
Klasse clsFiles:
Option Explicit
Dim mysArFiles() As String
Function searchFiles(sPath As String) As String()
Dim sArPath() As String
Dim sItem As String
Dim iCnt As Integer
’ U-Pfade finden
ReDim sArPath(1, 0)
sArPath(1, 0) = sPath
sArPath(0, 0) = 0
FindSubPath sArPath(), 0
Do While iCnt „“
If sItem „.“ And sItem „..“ Then
If GetAttr(sPath & sItem) = vbDirectory Then
ReDim Preserve sArPath(1, iCnt)
sArPath(1, iCnt) = sPath & sItem
sArPath(0, iCnt) = 0
iCnt = iCnt + 1
End If
If IsSearchedItem(sItem) Then
AddFoundSearchedFile sPath & sItem
End If
End If
sItem = Dir
Wend
sArPath(0, ItemToCheck) = 1
End Sub
Private Sub AddFoundSearchedFile(sItem As String)
On Error GoTo Err_Handler
Dim uB As Integer
uB = UBound(mysArFiles)
uB = uB + 1
ReDim Preserve mysArFiles(uB)
mysArFiles(uB) = sItem
uB = UBound(mysArFiles)
Err_Exit:
Exit Sub
Err_Handler:
uB = -1
Resume Next
End Sub
Function IsSearchedItem(sFile As String) As Boolean
If Len(sFile) >= 5 Then
IsSearchedItem = VBA.CBool(LCase(Mid(sFile, Len(sFile) - 4, 4)) = „.doc“)
Else
IsSearchedItem = False
End If
End Function
=========================================
Klasse clsFiles Ende
Modul modStart:
Sub ReplaceAuthor()
Dim myFiles As New clsFiles
Dim sFiles() As String
Dim sItem As Variant
Dim Doc As Document
sFiles = myFiles.searchFiles(„C:\Daten\Authortest“)
On Error Resume Next
For Each sItem In sFiles
Set Doc = Nothing
Set Doc = Application.Documents.Open(sItem)
If Err.Number 0 Then
If MsgBox(„Beim Öffnen der Datei „““ & sItem & „“" trat ein Fehler auf. Sollen weitere Dateien geöffnet werden?", vbQuestion + vbYesNo) vbYes Then
Exit For
End If
End If
If Not Doc Is Nothing Then
If Not Doc.BuiltInDocumentProperties(„Author“) = Application.UserName Then
Doc.BuiltInDocumentProperties(„Author“) = Application.UserName
Doc.Close saveChanges:=True
End If
Next
End Sub
===========================================
Modul modStart Ende
Im Modul modStart ist ein Pfad angegeben worden, der je nach Bedarf angepasst werden muss.
Für den Such- und Ersetzungsvorgang muss anschließend lediglich der Befehl ReplaceAuthor durchgeführt werden.
Viel Erfolg.
Grüße,
BigBen