MACSCRPT Archives

June 2010

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Deivy Petrescu <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 5 Jun 2010 17:06:58 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (66 lines)
On Jun 5, 2010, at 2:36 PM, Nobumi Iyanaga wrote:

> Hello again,
> 
> I am more and more intrigued. I found a document in Internet (in Japanese) explaining AppleScript scripting with MS Word. It says:
> 
> You can execute an AppleScript like this:
> 
> save as active document file name "Temp.doc"
> 
> where file name must be the name of the file or its file path.
> 
> So, I tried the following code:
> 
> set fpath to "Macintosh HD:Users:[me]:Documents:Backup:mydocfile.doc"
> set convert_fpath to "Macintosh HD:Users:[me]:Documents:mydocfile.rtf"
> 
> tell application "Microsoft Word"
> 	activate
> 	open fpath
> 	save as active document file name convert_fpath file format format rtf
> 	close active document
> end tell
> 
> and it worked perfectly. Then I tried:
> 
> set fpath to "Macintosh HD:Users:[me]:Documents:Backup:mydocfile.doc"
> 
> set convert_fpath to my replace_doc_with_rtf_MacPath(fpath)
> 
> tell application "Microsoft Word"
> 	activate
> 	open fpath
> 	save as active document file name convert_fpath file format format rtf
> 	close active document
> end tell
> 
> on replace_doc_with_rtf_MacPath(fpath)
> 	set perl_scpt to "$_ = shift; s/\\.doc$//; s/$/\\.rtf/; print;"
> 	
> 	return (do shell script "perl -e '" & perl_scpt & "' " & quoted form of fpath)
> end replace_doc_with_rtf_MacPath
> 
> Now, it says:
> 
> Microsoft Word got an error: active document doesn't understand the save as message.
> 
> I don't understand at all. What am I doing wrong...?
> 
> Thank you in advance for any insight.
> 
> Best regard,
> 
> Nobumi Iyanaga
> Tokyo,
> Japan
> 
> 

Nobumi,
 ditch the quoted form!
You are working with Mac path not Unix path, you don't need the quoted form

Deivy Petrescu
[log in to unmask]

ATOM RSS1 RSS2