I'm trying to use text from a Microsoft Word Doc to paste file names

I have a MS Word Doc that has a list which coincides with a library of sound files. I am trying to copy the text from Word and paste it as the name of the selected file in my foremost finder window. When the script gets to the task of renaming the file I get the following message.
Application “Finder” got an error: "Can’t set name to “Text from MS Word”

Can anyone help me. I’m new to this stuff and I’m floundering

tell application "Microsoft Word"
	activate
	do Visual Basic "	Selection.EndKey Unit:=wdLine, Extend:=wdExtend"
	cut
end tell
tell application "Finder"
	activate
	select Finder window 1
	get selection
	set name to (the clipboard as text)
	
end tell


Chris

Chris:

Try this out:

tell application "Microsoft Word"
	set a to content of text object of selection
end tell
set b to choose file with prompt "Choose file to rename:"
tell application "Finder" to set b's name to a

Is that pretty close to what you want?

Hey Cas,

Thanks for the response. I used the script but it told me that my object wasn’t defined. What am I doing wrong?

Chris

In order for my script to work, you need to have selected (highlighted) the text in the Word document that will become the new name for the file you choose.

Can you get the text of your Word document out as a list?

Is there any way to match up your music files from the list without manually doing it?

If you can’t do it automatically, here’s an easier approach without copying/pasting (if you can get a list out of your word Doc)

  1. Create a simple AS droplet that gets the name of itself then changes the name of the dropped file to that name.

  2. Write another script that takes your list and duplicates the above droplet for each item in your list, renaming each copy of the droplet tha same as each item in file.

  3. Open the window with your files to rename next to a window containing the new droplets, drag each of your files to the corresponding droplet.

May sound a bit confusing… any ??'s post back!

-N

Nedloh,

I understand the concept of what you are talking about but a bit over my head. Do you have an example script?

Thanks
Chris