Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 



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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:19 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