#1
|
|||
|
|||
VBA to split Word document into multiple documents
Hey guys, I have a very large document I need to split into multiple documents. Each section starts with a style called PageTitle for its main title, so I need the code to split for every PageTitle instances throughout the document. I've found some code online and wondered how I can update it. I also need the documents to be saved to my H:/ drive in a specific folder. Any help would be appreciated. Many thanks, Shelley
Code:
Sub SplitNotes(delim As String, strFilename As String) Dim doc As Document Dim arrNotes Dim I As Long Dim X As Long Dim Response As Integer arrNotes = Split(ActiveDocument.Range, delim) Response = MsgBox("This will split the document into " & UBound(arrNotes) + 1 & " sections.Do you wish to proceed?", 4) If Response = 7 Then Exit Sub For I = LBound(arrNotes) To UBound(arrNotes) If Trim(arrNotes(I)) <> "" Then X = X + 1 Set doc = Documents.Add doc.Range = arrNotes(I) doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000") doc.Close True End If Next I End Sub Sub test() 'delimiter & filename SplitNotes "///", "Notes " End Sub |
#2
|
|||
|
|||
You might start with this. I haven't used it in awhile so not sure if it will do your job or not:
Document Splitter |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
split word document based on bookmarks with each new document title of the bookmark | megatronixs | Word VBA | 9 | 09-05-2020 02:29 PM |
Extract Document ID and description from header in multiple Word documents and paste in new word doc | venkat_m | Word VBA | 2 | 05-23-2020 03:57 AM |
Mail Merge - split merged documents and rename each split document based on text in header | FuriousD | Word VBA | 1 | 05-12-2019 04:06 AM |
Switch between multiple Word documents within the same Word document | kai | Word VBA | 2 | 11-20-2017 10:13 PM |
Split one Word Document into Multiple PDFs | VieraOfficeUser | Word | 3 | 07-30-2014 10:58 PM |