![]() |
|
#2
|
||||
|
||||
|
Maybe something like. I left in the numbering.
Code:
Option Explicit
Sub SplitNotes(delim As String)
Dim doc As Document
Dim arrNotes As Variant
Dim strPath As String
Dim strFilename As String
Dim I As Long
Dim X As Long
Dim oPara As Range
Dim Response As Integer
ActiveDocument.Save
strPath = ActiveDocument.Path
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(Template:=ActiveDocument.FullName)
doc.Range = arrNotes(I)
Set oPara = doc.Paragraphs(1).Range
oPara.End = oPara.End - 1
strFilename = oPara.Text & Chr(32)
doc.SaveAs strPath & "\" & strFilename & Format(X, "000")
doc.Close True
End If
Next I
lbl_Exit:
Set doc = Nothing
Exit Sub
End Sub
Sub test()
'delimiter
SplitNotes "XXX"
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Splitting Word Document based on line content | TwiceOver | Word VBA | 23 | 10-12-2015 02:01 PM |
| Document Filename Generator for Referencing | john.adams | Word | 10 | 03-26-2013 12:14 AM |
| Document splitting | MsLavigne | Word | 2 | 05-09-2012 05:52 AM |
Save Filename using Document Text
|
Knawl | Word | 11 | 10-10-2011 03:00 AM |
WORD 2003 Need help splitting a HUGE Document
|
dlawson | Word | 4 | 04-14-2009 12:22 PM |