Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-04-2015, 05:00 AM
Julian Julian is offline Filename after splitting document Windows 7 64bit Filename after splitting document Office 2013
Novice
Filename after splitting document
 
Join Date: Dec 2015
Posts: 3
Julian is on a distinguished road
Default Filename after splitting document

hey everybody, I have a big word document that I want to split automaticly into a large number of smaller documents. I found this code below, that works perfectly. I just have one question. The code names the new documents Notes1, Notes2, Notes3 ect. but I would like to give them the respective first text line in the document (always 6 words) as document titles.
Is that possible and if yes, how do I have to change the code?
Thank you very much for your help!!!

Quote:
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 "XXX", "Notes "
End Sub
Reply With Quote
 



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
Filename after splitting document Save Filename using Document Text Knawl Word 11 10-10-2011 03:00 AM
Filename after splitting document WORD 2003 Need help splitting a HUGE Document dlawson Word 4 04-14-2009 12:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft