Für meine Arbeit mache ich Produktspezifikationen. Ich habe eine Tabelle mit allen Daten und ein Standard-Word-Dokument, wo die Daten eingefügt werden müssen. Ich mache dies mit der integrierten Serienbrieffunktion von Word. Allerdings muss ich seperat die Dokumente speichern, und ich fand den folgenden Code dafür:Speichern Sie Dokumente mit den Daten aus Seriendruck
Sub BreakOnSection()
' Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection
'A mailmerge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)
'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy
'Create a new document to paste text from clipboard.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Das spart die Dokumente als Test 1, Test 2 usw.
Ich möchte die Dokumente speichern mit eines der Datenelemente, die ich für den Seriendruck verwende. Gibt es eine Möglichkeit, dies zu tun?