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
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
27-Jan-2009, 10:17 AM #31
The code says
ActiveDocument.SaveAs (vPath & vFrom & ".doc")
where vPath is earlier defined as
vPath = ActiveDocument.Path & "\"
so it either should be in the same folder or one folder deeper in that folder (I'm not sure which, but I think the first) as where the original document is.
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
27-Jan-2009, 05:10 PM #32
You are correct Slurpee. The files get saved to the same path as the original document. That is why you should save the original document to your own location instead and not run the macro directly on a doc opened from email.

Regards,
Rollin
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
27-Jan-2009, 05:40 PM #33
Rollin, just a question. Given that all the resumes start with "bob@bobsaddress" won't they all be named the same, e.g. C:\\desktop\bob@bobsaddress.doc?
Or will it automatically call them bob@bobsaddress.doc, bob@bobsaddress2.doc, bob@bobsaddress3.doc, etc.?
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
27-Jan-2009, 10:46 PM #34
Quote:
Originally Posted by slurpee55 View Post
Rollin, just a question. Given that all the resumes start with "bob@bobsaddress" won't they all be named the same, e.g. C:\\desktop\bob@bobsaddress.doc?
Or will it automatically call them bob@bobsaddress.doc, bob@bobsaddress2.doc, bob@bobsaddress3.doc, etc.?
All the docs would be named the same. I just assumed that the addresses in the real doc would be different and that the op used the same address for demonstration purpose in the sample document. I guess we need more clarification about that.

Regards,
Rollin
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
28-Jan-2009, 07:07 AM #35
Hi All,

Actually the files to split do all start with the same email ID as they are emailed cvs from the same sender which were saved from Outlook into a single .txt file which i have converted to .doc

Each file that needs to be split is a different cv, so they all contain one differentiating email ID, but the beginning (where the split should occure) does not change, it's always bob@...
Ideally it would be great if they were saved by the different email IDs, but if they are saved to a number that works too.

When I run the macro, it seems to work (i can see lots of files Document1... Document2... etc being opened) but I end up with one single file under the name bob_bobsaddress.com.doc. My guess is they are overwriting each other as they are being saved under the same name.


Thank you all for your input and help!
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
28-Jan-2009, 09:41 AM #36
Just save each file with an incrementing counter variable. See updated code below.

Code:
Sub SplitFiles()

vPath = ActiveDocument.Path & "\"

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

vFirstRecord = True
i = 1

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 & "_" & i & ".doc")
i = i + 1
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 & "_" & i & ".doc")
Application.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...
28-Jan-2009, 10:31 AM #37
Great, now they will be named bob@bobsaddress.doc, bob@bobsaddress2.doc, bob@bobsaddress3.doc, etc.
It will be your problem, Miss HK, to open each and then rename them as you desire, but Rollin (once again) has done most of the work with code.
I am not sure Rollin, but could you not, given the facts of the layout of the big doc, add a new loop that would select "To:" and call that, say, vTo, and then change the naming to be
ActiveDocument.SaveAs (vPath & vTo & "_" & i & ".doc") ?
__________________
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!
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
29-Jan-2009, 10:08 AM #38
Thank you!!!
This is fantastic thank you soooo much! I will be sure to make a donation!!! I'm so ecstatic, genius, thank you, thank you, thank you!!!

Just one thing I then use a software to parse the files and but for some reason it doesnt work. For the parsing software to function i need to re-save the doc file into another doc file... any suggestions why that may be?
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
29-Jan-2009, 10:18 AM #39
What kind of parsing are you trying to do with your software? And what software are you using? We may be able to assist more....
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
29-Jan-2009, 10:55 PM #40
Quote:
For the parsing software to function i need to re-save the doc file into another doc file.
Can you elaborate on this?

Are you saying you have to reopen the doc and then re-save with a new filename?

Are you opening the doc and copying and pasting the contents into a new doc?

Are you opening a new doc and inserting the old doc via the insert menu?


Regards,
Rollin

Last edited by Rollin_Again; 29-Jan-2009 at 11:04 PM..
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
01-Feb-2009, 05:30 AM #41
Yes I am opening the file in word and re-saving under a different name.

I am testing this resume parsing software: http://go4resume.com/uploaddemo/demo.aspx to extract essential contact info and resumes

I first run the macro which works fine. But when I use the parsing trial from the link above on any of the files that have been split, the parsing results is this:

[Content_Types].xml
_rels/.rels
word/_rels/document.xml.rels
word/document.xml
word/theme/theme1.xml
word/settings.xml
word/fontTable.xml
word/webSettings.xml
docProps/app.xml
docProps/core.xml
word/styles.xml

So I open the same document go to save as, and save in a different name, as MS Word 97-2003 and when i test the parsing software again, it works fine. I have checked the properties and both the original and renamed files are in MS Word 97-2003 Document type.

I am contacting the software's support, will see what their feedback is.

Cheers!
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
01-Feb-2009, 10:12 AM #42
A thought:

Each file begins with the same as the sender and the recipient (me) are always the same:

To: bob@bobaddress.com
From: me@myemail.com

The layout of each email is pretty much the same

As each file that needs to be split is someone's cv, each file contains a line:

janedoe@hotmail.com <mailto:janedoe@hotmail.com>

the next file to split would also contain:

johndoe@yahoo.com <mailto: johndoe@yahoo.com>

Would it not be possible to save using <mailto:janedoe@hotmail.com>

so that each file gets saved with a different email ID, if the @ had to be changed to _ that wouldn't be a problem, but it would be great if i could differenciate the file by name/email ID rather than have each one saved as bob@bobaddress1.com, bob@bobaddress2.com etc

Thanks so much!

Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
01-Feb-2009, 11:26 AM #43
Here is the updated code to save the documents with the correct filename.

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.Find.Text = "mailto:"
Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Replace(Replace(Selection.Text, "mailto:", ""), ">", ""), "@", "_")
vFrom = Replace(vFrom, Chr(9), "")
vFrom = Trim(Replace(vFrom, Chr(13), ""))
Selection.HomeKey Unit:=wdStory

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

ActiveDocument.Close
vFirstRecord = True
Selection.Find.Text = "From:"
Else

vFirstRecord = False

End If

Loop

Selection.HomeKey Unit:=wdStory
Selection.Find.Text = "mailto:"
If Selection.Find.Execute = False Then
MsgBox ("Can't auto-save Last Document.  Please Save Manually")
End
Else
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
vFrom = Replace(Replace(Replace(Selection.Text, "mailto:", ""), ">", ""), "@", "_")
vFrom = Replace(vFrom, Chr(9), "")
vFrom = Trim(Replace(vFrom, Chr(13), ""))
Selection.HomeKey Unit:=wdStory
End If

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

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

End Sub
Regards,
Rollin
Miss HK's Avatar
Junior Member with 21 posts.
 
Join Date: Jan 2009
Experience: Beginner
05-Feb-2009, 03:11 AM #44
Hi,

This is great, thank you!!!!! Do you have any suggestions with regards to my parsing issue mentioned earlier?

Yes I am opening the file in word and re-saving under a different name.

I am testing this resume parsing software: http://go4resume.com/uploaddemo/demo.aspx to extract essential contact info and resumes

I first run the macro which works fine. But when I use the parsing trial from the link above on any of the files that have been split, the parsing results is this:

[Content_Types].xml
_rels/.rels
word/_rels/document.xml.rels
word/document.xml
word/theme/theme1.xml
word/settings.xml
word/fontTable.xml
word/webSettings.xml
docProps/app.xml
docProps/core.xml
word/styles.xml

So I open the same document go to save as, and save in a different name, as MS Word 97-2003 and when i test the parsing software again, it works fine. I have checked the properties and both the original and renamed files are in MS Word 97-2003 Document type.
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
05-Feb-2009, 08:47 AM #45
I am not sure why the documents aren't getting parsed correctly. When I run the macro on the sample file you emailed me and then try to parse one of the resulting documents it appears to work fine. I am unable to duplicate your results and without having a "real" document to test it's going to be hard to troubleshoot this issue. Have you been able to get any help from the software vendor? What version of MS Word are you using?

Regards,
Rollin
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:45 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.