i have word document of 700 pages that i want split based on page number ie:- after every 4 pages it should split and save as new file and the file name must be the criteria of page 1
split word document
-
-
Re: split word document
Hi sachin483
The basic way is like....Code
Display MoreOption Explicit Sub Split_Pages() Dim docExisting As Document, docNew As Document Dim RangePage As Range Dim intLastPageNum As Long, intLastPage As Long, strNewFile As String Set docExisting = ActiveDocument Set RangePage = docExisting.Range intLastPage = docExisting.Content.ComputeStatistics(wdStatisticPages) intLastPageNum = 1 Do Until intLastPageNum > intLastPage If intLastPageNum = intLastPage Then RangePage.End = ActiveDocument.Range.End Else: Selection.GoTo wdGoToPage, wdGoToAbsolute, intLastPageNum + 4 RangePage.End = Selection.Start End If RangePage.Copy Set docNew = Documents.Add docNew.Range.Paste docNew.Range.Find.Execute Findtext:="^m", ReplaceWith:="" strNewFile = Replace(docExisting.FullName, ".doc", intLastPageNum & " to " & intLastPageNum + 4 & ".doc") docNew.SaveAs strNewFile intLastPageNum = intLastPageNum + 4 docNew.Close RangePage.Collapse wdCollapseEnd Loop Set docExisting = Nothing Set docNew = Nothing Set RangePage = Nothing End Sub
-
Re: split word document
Thanks for macro but i have formatted the word file with landscape mode it is coming portrait and can the file name be the criteria based on line of 3 or 4 and i have kept the minimum margin for the word document, so the margin can also be fixed which was kept for original document
-
Re: split word document
sachin483
can you attach the document -
Re: split word document
sorry for the delay
the format and font should remained same if it is landscape mode the it should split in landscape or if portrait then portrait,after split the file name will the search criteria
for example i want split the file by searching the key word -XP01 there are 4 pages it should create a new word file and append all the pages one below another like that i have around 500 pages in word which i have to separate based on criteria
-
-
Re: split word document
hmmm..
too many variables with different word documents and formats page break rectangles shapes ect.....
for the document suppled .. make a copy and runCode
Display MoreOption Explicit Sub test_Only_On_Dummy_Data() Dim lngPage As Long, objPage As Range With ActiveDocument For lngPage = .ComputeStatistics(wdStatisticPages) To 1 Step -1 Set objPage = ActiveDocument.GoTo(What:=wdGoToPage, Name:=lngPage) Set objPage = objPage.GoTo(What:=wdGoToBookmark, Name:="\page") With objPage With .Find .Execute FindText:="XP01" If Not .Found = True Then objPage.Delete End If End With End With Next End With End Sub
all that will be left will be the pages with XP01 in them
-
Re: split word document
Thanks a lot you made my day...........
-
Re: split word document
glad to help and your so easily pleased .. enjoy the day
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!