Hello! Do you have a question about Windows Server or Windows Client for IT Pros?
Please note that both categories together with questions have been moved to Microsoft Q&A. This change will help us provide a more streamlined and efficient experience for all your questions and discussions.
Hello! Do you have a question about Windows Server or Windows Client for IT Pros?
Please note that both categories together with questions have been moved to Microsoft Q&A. This change will help us provide a more streamlined and efficient experience for all your questions and discussions.
I have a large word document, which happens to be a song book, that has multiple songs on one page. I am wanting to seperate each song into it owns document and use the name of the song as the document file name.
I have gone in and started doing this by copying and pasting each song into its own seperate document, but this takes forever and I was wanting to automate this process by using VBA code.
While your document starts out with Heading 1 style being used for the titles, it does not do that all the way through and there a various other issues that need to be fixed before a macro can
be used to create individual files.
After a bit of manual editing to apply the Heading 1 style to all of the song titles and removing multiple consecutive instances of that style in a number of places and
using the replace facility and number of times to remove other irregularities and then finally using it to replace Heading 1 style paragraphs by ^m^& in the replace control to get the document to the point where each song started on a new page , I then used
the following macro to create separate files for each song, named with the title of the song
Dim Counter As Long, Source As Document, Target As Document
Set Source = ActiveDocument
Dim Pages As Long
Dim rngDocName As Range
Dim strDocName As String, strFolder As String
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Title = "Select the folder into which the documents will be saved."
If .Show = -1 Then
strFolder = .SelectedItems(1) & "\"
Else
MsgBox "The documents will be saved in the default document file location."