Re: MS Word Save as TEXT - Newbie
Re: MS Word Save as TEXT - Newbie
- Subject: Re: MS Word Save as TEXT - Newbie
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 21 Apr 2003 22:53:49 -0700
On 4/21/03 9:52 PM, "Shane Stanley" <email@hidden> wrote:
>
> How do you save as type "TEXT" in MS Word (or better still "Text with
>
> Line breaks")
>
>
>
> I have hundreds of word and RTF files that require import into
>
> Filemaker Pro - and hence I need to convert them first to a text format.
>
>
>
> The script fails on "SAVE doc_ref in "New_file.txt" as "something"
>
>
>
> ...what is a "Type class", and how do I access it?
>
>
save document 1 in file pathToNewFile as "Text Only"
You will probably want to replace ".doc' and ".rtf" by ".txt" and also
change the creator type to "ttxt" so it doesn't open in Word (if you have
it) but in TextEdit. The following script does those, plus gives you an
alternative method for "Save As" in case the one above starts acting up.
(You'll know what I mean if it does.) Unwrap long lines. ()This version
makes a second file with '.txt' extension.
set aWordDocPath to "Mac HD:Users:you:a Folder:Some WordDoc.doc" --or
whatever
--use string path [alias 'as string' if necessary
tell application "Microsoft Word"
do Visual Basic "
Documents.Open FileName:=\"" & aWordDocPath & "\"
ActiveDocument.SaveAs FileName:=\"" & textDocPath & "\",
FileFormat:=wdFormatText
ActiveDocument.Close
"
end tell
tell application "Finder"
set wordDocFile to file aWordDocPath
tell wordDocFile
set {creator type, file type, fileName} to {"ttxt", "TEXT", name}
end tell
if aWordDocPath contains "." then
set AppleScript's text item delimiters to {"."}
--remove (.doc or .rtf) extention
set fileName to ((text items 1 thru -2 of fileName) as string) &
".txt"
set AppleScript's text item delimiters to {""}
else
set fileName to (fileName & ".txt")
end if
set name of wordDocFile to fileName
end tell
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.