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 batch bios bsod crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram registry router server 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
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Separate huge .doc file into multiple files

Reply  
Thread Tools
computerman29642's Avatar
Computer Specs
Senior Member with 2,794 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Always Learning!
14-Jan-2009, 01:43 PM #16
So, we need automatic page breaks? Let me see what I can come up with.
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
14-Jan-2009, 08:35 PM #17
Does the phrase "NEW FILE" actually appear between each new entry in the Word file or did you just place it there to help with your explantion?

Also, you will not be able to use the exact email address as the filename since it contains a special character (@)

You can always replace this symbol with an underscore or other character and save it that way. Would that work?

Regards,
Rollin

Last edited by Rollin_Again; 14-Jan-2009 at 08:56 PM..
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
15-Jan-2009, 04:15 AM #18
Hi Rollin_Again!


Basically, it's a 100 resumes all in one Word file that I need to split up into as many resumes.

The beginning of each resume is always the same:
From: bob@bobsaddress.com

I'd like to save by name or email id, changing @ to underscore isn't ideal cause i'll have to manually find and replace each file with @ again afterwards, could i just save each file with the name before @ ?

Here is an actual sample of the file:

From: bob@bobsaddress.com
Sent: Wednesday, October 31, 2007 2:04 PM
To: me@myemail.com
Subject: CANADA
----------------------------------------------------------------------
#11111111
----------------------------------------------------------------------
Name: kris
Address:
Email: kris@krismail.com
----------------------------------------------------------------------

CONTACT INFO
kris
kris@krismail.com
RESUME
#11111111
Resume
Text Missing


From: bob@bobsaddress.com
Sent: Wednesday, October 31, 2007 2:04 PM
To: me@myemail.com
Subject: DESIGN
----------------------------------------------------------------------
#88888888
----------------------------------------------------------------------
----------------------------------------------------------------------
Name: jane
Address
Email: jane@janemail.com
----------------------------------------------------------------------

CONTACT INFO
Jane
jane@janemail.com
RESUME
#88888888
Headline:
Text Missing
----------------------------------------------------------------------


From: bob@bobsaddress.com
Sent: Wednesday, October 31, 2007 2:04 PM
To: me@myemail.com


I tried modifying the code you created but I know nothing about VBS!
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
15-Jan-2009, 10:20 AM #19
That is much more useful for practical work. So, you could insert a page break before every point where "From: bob" appears?
Anne Troy's Avatar
Computer Specs
Moderator with 11,785 posts.
 
Join Date: Feb 1999
Location: Columbia, MD
Experience: Microsoft Word MVP
15-Jan-2009, 10:36 AM #20
First run this macro, which I recorded and main not be incredibly efficient, but should be fine for your purposes:

Code:
Sub MakeBreaks()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "From: "
        .Replacement.Text = "DELIMITERFrom: "
        'Your delimiter is the word DELIMITER, above
        .Forward = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.HomeKey Unit:=wdStory
    Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
Then use the word DELIMITER in this macro, to separate the files:

http://vbaexpress.com/kb/getarticle.php?kb_id=922

If you have questions or problems, ask Steve Lucas, who wrote the macro, at vbaexpress. He's a great guy.
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
15-Jan-2009, 10:56 AM #21
Nice Anne, but all it does is give you a place to insert page breaks. That is just as easily accomplished with a variation of what I posted in #9

Replace "From: bob" with "^mFrom: bob" and you will have manual page breaks in front of every place that "From: bob" occurs
(The "^" means page break in "Word" and "m" means manual)
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.
My theme song... | Affero - rate me!
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
16-Jan-2009, 01:24 AM #22
Try this macro. Make sure to ALWAYS save a backup copy of the original Word document before running any macro code on it.

Code:
Sub SplitEmails()

vPath = ActiveDocument.Path & "\"

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = "From:"

vFirstRecord = True

Do While Selection.Find.Execute = True

If vFirstRecord = False Then

Selection.MoveUp Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Cut
Documents.Add DocumentType:=wdNewBlankDocument
Selection.Paste
Selection.HomeKey Unit:=wdStory

Do While Selection.Text <> "F"
Selection.Delete Unit:=wdCharacter, Count:=1
Loop

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Left(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"), Len(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"))), Chr(11), "")
ActiveDocument.SaveAs (vPath & vFrom & ".doc")
ActiveDocument.Close
vFirstRecord = True

Else

vFirstRecord = False

End If

Loop

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Left(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"), Len(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"))), Chr(11), "")
Selection.HomeKey Unit:=wdStory

Do While Selection.Text <> "F"
Selection.Delete Unit:=wdCharacter, Count:=1
Loop

ActiveDocument.SaveAs (vPath & vFrom & ".doc")
ActiveDocument.Quit

End Sub
Regards,
Rollin
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
16-Jan-2009, 09:27 AM #23
Looks good, Rollin! I hope you are enjoying this nice warm winter!
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
20-Jan-2009, 05:53 AM #24
Sadly it's not working error message: 4198

Debugger points to: ActiveDocument.SaveAs (vPath & vFrom & ".doc")

Am I doing something wrong?
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
20-Jan-2009, 09:41 AM #25
Add the following line just before the line that is throwing the error and then tell us what the messagebox says. What version of MS Word are you using? The only other thing I can think of is that you are using Word 2007 which would require that you change the file extension from .doc to .docx or similar. I tested the code on my earlier version of Word and did not recieve any errors.

Code:
Msgbox(vPath & vFrom & ".doc")
Regards,
Rollin
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
21-Jan-2009, 12:06 PM #26
Duh...

Actually I tried converting my file from docx to doc and changing the code .doc to .docx but it seems to always split the first cv and the i get the msg error.

When I entered the line as you advised I first get a box that says:

C:\Documents and Settings: User\My Documents\ filename\ route.xxxxx.com.doc

When I click OK it is followed by another box: Run Time Error '4198'

Command failed

And so only the first file has been split
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
22-Jan-2009, 09:04 AM #27
Without an actual sample doc it will be hard to determine why the macro is not working. I copied and pasted the text from one of your previous posts straight into a new doc and resaved it before running the macro and it worked fine. If you want to send me a sample via email I'd be happy to take a look. Just replace any sensitive data and reduce the total size to include only about 5 or six entries.

Does the filename route.xxxxx.com.doc contain any special characters such as apostrophe or single quote mark?

When you get the runtime error it should give you the option to debug. Click debug and tell me which line of code is highlighted.


Rollin_Again at Hotmail dot com
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
25-Jan-2009, 09:50 AM #28
OK I got your sample document you sent me via email. It looks like the reason the code was failing was because the FROM: line contains two special characters that cannot be used in the SaveAs filename. These special characters are the Tab character and the Carriage Return character. I have modified the code to replace these characters with nothing. Just add the following two lines of code before each of the two save commands (ActiveDocument.SaveAs)


Code:
vFrom = Replace(vFrom, Chr(9), "")
vFrom = Replace(vFrom, Chr(13), "")
Your final code should appear as it does below. Make sure that you ALWAYS maintain duplicate copies of documents prior to running any macros on them. Also, the document that you are running the macro on should also be saved locally to your disk instead of opening directly from an email and running the macro. If you open a document straight from your email and do not save to your hard disk the individual docs will be saved to the temp files directory where they may be lost after being written.

Code:
Sub SplitFiles()

vPath = ActiveDocument.Path & "\"

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = "From:"

vFirstRecord = True

Do While Selection.Find.Execute = True

If vFirstRecord = False Then

Selection.MoveUp Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Cut
Documents.Add DocumentType:=wdNewBlankDocument
Selection.Paste
Selection.HomeKey Unit:=wdStory

Do While Selection.Text <> "F"
Selection.Delete Unit:=wdCharacter, Count:=1
Loop

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Left(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"), 

Len(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"))), Chr(11), "")
vFrom = Replace(vFrom, Chr(9), "")
vFrom = Replace(vFrom, Chr(13), "")
ActiveDocument.SaveAs (vPath & vFrom & ".doc")
ActiveDocument.Close
vFirstRecord = True

Else

vFirstRecord = False

End If

Loop

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Left(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"), 

Len(Replace(Trim(Mid(Selection.Text, 6)), "@", "_"))), Chr(11), "")
vFrom = Replace(vFrom, Chr(9), "")
vFrom = Replace(vFrom, Chr(13), "")
Selection.HomeKey Unit:=wdStory

Do While Selection.Text <> "F"
Selection.Delete Unit:=wdCharacter, Count:=1
Loop

ActiveDocument.SaveAs (vPath & vFrom & ".doc")
Application.Quit

End Sub
Regards,
Rollin

Last edited by Rollin_Again; 25-Jan-2009 at 10:08 AM..
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
25-Jan-2009, 09:59 AM #29
sweet work, Rollin! hope it works!
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
27-Jan-2009, 10:09 AM #30
Almost there thank you! I run the macro, and it seems to work, but I can't find the files, I'm not sure where they have been saved.
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 02:50 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.