Extracting and saving multiple files from single file

J

John

I have a large Word file with the words to hundreds of
songs. My Macro extracts each individual song, place it in
a new file, extract the file name from the file and
attempts to Save As (the extracted File name). How do I
get the file name to change. I have only been sucessful in
getting a single file name. See Example:

ActiveDocument.SaveAs FileName:="Dummy.doc",

I don't know how to setup a variable to use the extracted
(Selection.Cut) file name.
 
J

Jonathan West

Hi John,

If you have text selected that you want as the filename, then proceed as
follows

Dim sFileName as String
sFileName = Selection.Text & ".doc"
ActiveDocument.SaveAs FileName:=sFileName
 
W

Word Heretic

G'day "John" <[email protected]>,

ActiveDocument.SaveAs FileName:=Selection.Range.Text

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


John was spinning this yarn:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top