View Single Post
Old 02-18-2010, 12:49 PM
MJMR999 MJMR999 is offline Windows Vista Office 2007
Join Date: Feb 2010
Posts: 2
MJMR999 is on a distinguished road
Default Macro to export document sections to individual txt files?

Hey guys, this is something that I believe should be possible but I have no idea how to go about it. I work on ebooks in Word constantly (for myself, not for work or distributing) and I set the various chapter titles as Heading 1. I need to output each chapter individually to a UTF-8 txt file with the chapter name as the filename. Since Word does allow you to copy/paste whole section by the Heading in Outline view it seems like it should be doable.

The way I do it right now is copy/paste from Word into Notepad++ one chapter at a time. Doing this repeatedly is a real pain, especially with 30-40 chapter ebooks.

For instance let's just say we have the following file, with bold being Heading 1.

Chapter 1
Sam went to the store.
Chapter 2
Sam came home.

What I want is a macro that would output Introduction.txt containing "Hi", Chapter 1.txt containing "Sam went to the store." and Chapter2.txt containing "Sam came home."

Any ideas how this might be done would be greatly appreciated!

Reply With Quote