Wurde doch nicht ganz Nacht
Folgendes kann Excel und Word Files umarbeiten.
Die Originale werden dabei überschrieben
Was Du dazu tun must:
Erstelle ein Word-Document und speicher es als .docm
Mit Alt+F11 in den VBA Editor wechseln, dort über [Einfügen] [Modul] ein Modul erstellen.
Über [Extras][Verweise] musst Du "Microsoft Excel x.x Object Library" einbinden
In das neue Modul kopierst Du dann folgenden Code
[src=vb]
Public Function fClearData()
Dim fd As FileDialog
Dim FileChosen As Integer
Dim FileName As String
Dim i As Integer
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = "C:\"
fd.InitialView = msoFileDialogViewList
'allow multiple file selection
fd.AllowMultiSelect = True
fd.Filters.Clear
'fd.Filters.Add.Extensions = "doc,docx"
fd.Filters.Add "Excel Files", "*.xls;*.xlt;*.xlsx;*.xlsm;*.xlsb"
fd.Filters.Add "Word Files", "*.doc;*.docx;*.docm;*.dot;*.dotx;*.dotm"
FileChosen = fd.Show
Dim strFile As String
If FileChosen = -1 Then
For i = 1 To fd.SelectedItems.Count
strFile = fd.SelectedItems(i)
If fd.FilterIndex = 1 Then
Debug.Print "excel"
Call fClearWorkbook(strFile)
End If
If fd.FilterIndex = 2 Then
Debug.Print "word"
Call fClearWordDoc(strFile)
End If
Next i
End If
End Function
Public Function fClearWorkbook(ByVal strWorkbook As String)
'Referenz zu Excel setzen! extras - > verweise -> Microsoft Excel x.x Object Library
Dim ea As Excel.Application
Dim wb As Excel.Workbook
Set ea = New Excel.Application
Set wb = ea.Workbooks.Open(strWorkbook)
With wb
.RemoveDocumentInformation xlRDIAll
.RemovePersonalInformation = True
.Save
End With
wb.Close
Set wb = Nothing
ea.Quit
Set ea = Nothing
End Function
Public Function fClearWordDoc(ByVal strWorddoc As String)
Dim wd As Word.Document
Set wd = Application.Documents.Open(strWorddoc)
With wd
.RemoveDocumentInformation wdRDIAll
.RemovePersonalInformation = True
.Save ' NoPrompt:=True, OriginalFormat:=wdOriginalDocumentFormat
End With
wd.Close
Set wd = Nothing
End Function
[/src]
und passt die Zeile
[src=vb]
fd.InitialFileName = "C:\"
[/src]
so an, dass das Verzeichnis mit den Files als Default gewählt wird.
Wenn Du nun den Cursor auf die Zeile
[src=vb]Public Function fClearData()[/src]
setzt und [F5] drückst, geht der ganze Spuk los
p.s.: Hab ich schon gesagt, dass ich VBA mag?