Hi guys,
Managed to split my document, as per my requirements.
Now the issue is, they are all named 'Notes 001, Notes 002 and so on'
I have found a macro that will rename the documents as per the first line.
The issue is, they all begin with the same first line.
I need it to basically find the section that says 'title:' and then rename the document as the text next to title. I have also discovered that 'title:', isn't always in the same place in the document.Sub GetRenameFiles() Dim fd As FileDialog Dim strFolder As String Dim strFile As String Dim aDoc As Document Dim rngNewName As Range Set fd = Application.FileDialog(msoFileDialogFolderPicker) With fd .Title = "Select the folder that contains the files." If .Show = -1 Then strFolder = .SelectedItems(1) & "\" Else MsgBox "You did not select a folder." Exit Sub End If End With strFile = Dir$(strFolder & "*.doc*") While strFile <> "" Set aDoc = Documents.Open(strFolder & strFile) Set rngNewName = aDoc.Paragraphs(1).Range rngNewName.MoveEnd wdCharacter, -1 aDoc.SaveAs2 rngNewName.Text aDoc.Close strFile = Dir$() Wend End Sub
Thanks




Reply With Quote