Microsoft Office Forums Help with splitting word doc and keeping the same font and style.

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2019, 08:58 AM
Berville141 Berville141 is offline Help with splitting word doc and keeping the same font and style. Windows 10 Help with splitting word doc and keeping the same font and style. Office 2016
Novice
Help with splitting word doc and keeping the same font and style.
 
Join Date: Nov 2019
Posts: 1
Berville141 is on a distinguished road
Default Help with splitting word doc and keeping the same font and style.

Hi all, I'm hoping you can help.
I'm currently running a project and I'm trying to break down a word doc which includes about 100 different letters individually, which I have made using mail merge.

I have been able to split the doc down however when i look at the new docs they are in a different format and I'm hoping you will be able to help me with this.

The script i have used is below:
Sub SplitIntoPages()
Dim docMultiple As Document
Dim docSingle As Document
Dim rngPage As Range
Dim iCurrentPage As Integer
Dim iPageCount As Integer
Dim strNewFileName As String
Application.ScreenUpdating = False 'Makes the code run faster and reduces screen _
flicker a bit.
Set docMultiple = ActiveDocument 'Work on the active document _
(the one currently containing the Selection)
Set rngPage = docMultiple.Range 'instantiate the range object
iCurrentPage = 1
'get the document's page count
iPageCount = docMultiple.Content.ComputeStatistics(wdStatisticP ages)
Do Until iCurrentPage > iPageCount
If iCurrentPage = iPageCount Then
rngPage.End = ActiveDocument.Range.End 'last page (there won't be a next page)
Else
'Find the beginning of the next page
'Must use the Selection object. The Range.Goto method will not work on a page
Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage + 4
'Set the end of the range to the point between the pages
rngPage.End = Selection.Start
End If
rngPage.Copy 'copy the page into the Windows clipboard
Set docSingle = Documents.Add 'create a new document
docSingle.Range.Paste 'paste the clipboard contents to the new document
'remove any manual page break to prevent a second blank
docSingle.Range.Find.Execute Findtext:="^m", ReplaceWith:=""
'build a new sequentially-numbered file name based on the original multi-paged file name and path
strNewFileName = Replace(docMultiple.FullName, ".doc", "_" & Right$("000" & iCurrentPage, 4) & ".doc")
docSingle.SaveAs strNewFileName 'save the new single-paged document
iCurrentPage = iCurrentPage + 1 'move to the next page
docSingle.Close 'close the new document
rngPage.Collapse wdCollapseEnd 'go to the next page
Loop 'go to the top of the do loop
Application.ScreenUpdating = True 'restore the screen updating
'Destroy the objects.
Set docMultiple = Nothing
Set docSingle = Nothing
Set rngPage = Nothing
End Sub




thanks in advance for your help
Reply With Quote
  #2  
Old 11-01-2019, 09:34 PM
gmayor's Avatar
gmayor gmayor is offline Help with splitting word doc and keeping the same font and style. Windows 10 Help with splitting word doc and keeping the same font and style. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,008
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

See Individual merge letters or Merge and Split

Without debugging your macro an obvious problem seems to be at
Code:
Set docSingle = Documents.Add 'create a new document
which will use the normal template. It would be preferable to use your merge document as a template.
Code:
Set docSingle = Documents.Add(Template:=docMultiple.FullName)
You might also bear in mind that a merged document is divided by sections, so you can use the sections to split the document which is rather less complicated than using the pages.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 11-02-2019, 10:54 PM
macropod's Avatar
macropod macropod is offline Help with splitting word doc and keeping the same font and style. Windows 7 64bit Help with splitting word doc and keeping the same font and style. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,612
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

See also Split Merged Output to Separate Documents (or, better still, Send Mailmerge Output to Individual Files) in the Mailmerge Tips and Tricks 'Sticky' thread at the top of this forum: Mailmerge Tips & Tricks
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2010 Having more than one font for same style heading normancamp Word 1 08-06-2018 02:21 PM
When changing table style in Word 2010, font size seems to change but doesn't show in new tables heartsoulliving Word 1 12-07-2016 05:17 PM
Help with splitting word doc and keeping the same font and style. Remove white text background (keeping the font color and page color intact cc3125 Word 1 10-26-2015 06:44 PM
Keeping Font Color Changes After Switching Slides Kazumi7677 PowerPoint 0 10-15-2014 08:29 PM
Help with splitting word doc and keeping the same font and style. Keeping Tables from Splitting Between Pages AlexPaoletti Word Tables 2 05-18-2010 01:17 AM


All times are GMT -7. The time now is 07:44 AM.


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