Hi,
So I am using this code to separate mail merged files into separate documents but I am having trouble defining a variable that would allow me to choose the names for these files.
I use this module to separate the files into individual ones, then they are named, 1.doc, 2.doc etc. Instead I want them to be named as the title of each document (Characters that are on the first line.)
Option ExplicitSub
AllSectionsToSubDoc()
Dim x AsLongDim
Sections AsLongDim
Doc As Document
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set Doc = ActiveDocument
Sections = Doc.Sections.Count
For x = Sections - 1 To 1 Step -1 Doc.
Sections(x).Range.Copy Documents.Add
ActiveDocument.Range.Paste
ActiveDocument.SaveAs (Doc.Path & "\" & x & ".doc")
ActiveDocument.Close False
Next x Application.Screen
Updating = True
Application.DisplayAlerts = True
End Sub
So for example, the documents are like
Sydney Airport
BLAG AHBLKJ
ADKJHSDF
and then
Melbourne Airport
SDJHFJS
AJHKSDJFH
etc.
I want the documents to be called Sydney Airport and Melbourne Airport etc.. Can someone help me modify the code to do this?
Thanks and let me know if I did anything wrong, I am new to the forum.