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 23:04:42 -0700
On 4/21/03 10:53:49:PM, I wrote:
>
tell application "Microsoft Word"
>
do Visual Basic "
>
Documents.Open FileName:=\"" & aWordDocPath & "\"
>
ActiveDocument.SaveAs FileName:=\"" & textDocPath & "\",
>
FileFormat:=wdFormatText ActiveDocument.Close
>
>
"
>
end tell
Now this is odd, and not the first time I've seen this. I had an earlier
version where I changed the file name in Word (in do VB), which resulted in
a second ".txt" file instead of converting the original .doc file. So I
changed it. But I forgot to change (or remove the now unnecessary) '
textDocPath ' variable. That's now undefined, but it didn't error when
running from the same script window as before. Very strange, It surely will
if anyone else tries it. Here's the fixed script:
set aWordDocPath to "Mac HD:Users:you:Some Folder:Some WordDoc.doc" --or
whatever
tell application "Microsoft Word"
do Visual Basic "
Documents.Open FileName:=\"" & aWordDocPath & "\"
ActiveDocument.SaveAs 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 fileName 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.