Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod crash desktop driver drivers error ethernet excel freeze games gaming hard drive hardware hdmi internet laptop malware memory missing monitor motherboard network printer problem ram random registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Separate huge .doc file into multiple files

Reply  
Thread Tools
stuswitzer's Avatar
Junior Member with 5 posts.
 
Join Date: Apr 2009
Experience: Intermediate
06-Apr-2009, 04:34 PM #61
I used Slurpee's post on page 1 and it worked great, but I want to modify it a bit. I want to run the process where i = 1 to 5 but then grab the rest of the document and put it into a new document regardless of how many sections are left. I can get the 1-5 to run but then I am a little lost on how my code should look.
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
07-Apr-2009, 07:27 AM #62
Quote:
Originally Posted by stuswitzer View Post
I used Slurpee's post on page 1 and it worked great, but I want to modify it a bit. I want to run the process where i = 1 to 5 but then grab the rest of the document and put it into a new document regardless of how many sections are left. I can get the 1-5 to run but then I am a little lost on how my code should look.
Looking at Slurpee's code on page 1. Replace the line after

Code:
Next i
and before
Code:
 
End Sub
with

Code:
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close 
HTH
stuswitzer's Avatar
Junior Member with 5 posts.
 
Join Date: Apr 2009
Experience: Intermediate
07-Apr-2009, 01:45 PM #63
that sort of worked, it grabbed all of the sections though. What I am looking to do is take sections 1-5 and save them all as individual documents and then take sections 6-x and have them as 1 big document.

My guess is that I need to somehow move to section 6 and make a selection of /EndOfDoc like we do for /section to complete this....

I've mad a few modifications to the code but here is what I am doing

Function BreakOnSection()
'
' BreakOnSection Macro
' Macro created 4/3/2009 by switze_s
'
' Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection

'A mailmerge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To 5

'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy

'Create a new document to paste text from clipboard.
Application.DisplayAlerts = False
Documents.Add
Selection.Paste

' Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

ChangeFileOpenDirectory "u:\"
DocNum = DocNum + 1
ActiveDocument.Save
ActiveDocument.Close
' Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Save
ActiveDocument.Close
End Function
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
07-Apr-2009, 03:37 PM #64
Quote:
Originally Posted by stuswitzer View Post
I used Slurpee's post on page 1 and it worked great
Stu, did you use the code from page 1 or page 4?
stuswitzer's Avatar
Junior Member with 5 posts.
 
Join Date: Apr 2009
Experience: Intermediate
07-Apr-2009, 04:25 PM #65
I grabbed the stuff from page 1 and have since made a few minor modifications. The code that was posted above includes all of the changes that I've made....I quite honestly didn't make it to page 4 because this code worked sufficiently until a new development popped up on me..
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
07-Apr-2009, 04:38 PM #66
In the first posting, this "For i = 1 To ((ActiveDocument.Sections.Count) - 1)" set the limit.
To use "For i = 1 To 5" to work, you need to set i=1 at the start and then, just before Next i, set i=i+1,
stuswitzer's Avatar
Junior Member with 5 posts.
 
Join Date: Apr 2009
Experience: Intermediate
07-Apr-2009, 04:54 PM #67
The 1-5 part is working though...what I need is to be able to get sections 6 and beyond into one document...The bit that Turbodante gave :

ActiveDocument.Save
ActiveDocument.Close


saved the entire document again, which looking at it now makes sense that it would do that...

I guess where my biggest disconnect is that I don't know how to make it say from section 6 to the end of the document to copy the range and paste it into the new document.
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
07-Apr-2009, 05:10 PM #68
I am not sure - try this with a test file, but what if you changed:
'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy
to
'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Cut
stuswitzer's Avatar
Junior Member with 5 posts.
 
Join Date: Apr 2009
Experience: Intermediate
07-Apr-2009, 05:25 PM #69
thought you might have been on to something there but it still gave me the entire document.

Edit: I take that back, hitting the save button after changing the code would have been handy....you're an evil genius and I am truly appreciative....thanks so much!!

Last edited by stuswitzer; 07-Apr-2009 at 05:35 PM..
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
07-Apr-2009, 05:39 PM #70
Quote:
Originally Posted by stuswitzer View Post
you're an evil genius
I am truly flattered!
But really, you worked it out with the help of my search - have fun with your document!
Reply

Tags
files, macro, split, word

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:22 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.