PDA

View Full Version : Split Word document and auto save



Arjan Kessel
04-01-2009, 04:08 AM
Hi! Unfortunately I can't find a full working example here on the forum, so this is my question...

I need a macro script that can split a Word document in pieces and auto save every new generated file on the hard disk.
I have a large document, and want to search for a string. Let's say this string is ""///". At this point, I want the macro to create a new Word document with the content between the first ""///" and the next ""///" and save the new document with a random filename or (better) a filename based on the first words / line of the new document. Is this possible?

I've found here a "Splitdoc" macro and this one is working well, but the new documents loses all the formatting of the original document. Of course I want to maintain the formatting.
And I can't find an example to auto save all the files.

Please help!

Thanks in advance,
Arjan

fumei
04-01-2009, 09:14 AM
"At this point, I want the macro to create a new Word document with the content between the first ""///" and the next ""///" and save the new document with a random filename or (better) a filename based on the first words / line of the new document. Is this possible?"

Yes this is possible.

"but the new documents loses all the formatting of the original document. "

If the new documents use the template of the original, then format should be retained...although you DO have to be using styles properly and well. If you are not...then this may be possible, but it may not be. It depends.

Arjan Kessel
04-01-2009, 11:41 PM
Thanks for you answer!
Can anyone please make an example vba macro? I am not a programmer.

Thanks in advance.

fumei
04-02-2009, 10:12 AM
"I am not a programmer. "

Fair enough, but are you not trying to do some programming with this? Try doing some looking and searching to get at least get some basic operation going. If you get into trouble with something specific - likely - then post a specific question.

You say the "SplitDoc" is working well...yet you also say you can't find an example to auto save the files. Does the splitdoc code not save the files?

As for the formatting, it is as I have already mentioned. It depends. Are you using styles correctly? if you are, then it can be done. If you are not, then it is much harder, and possibly can NOT be done.