Script to get documents from CD

Hi,

First time scripter, been pulling my hair out on this. It’s a fairly simple action (I think). I’ve looked all over for answers, and searched this bb as best I could.

Heres the project: (needs to work for OS 9 and X - ok if requires separate script for each OS)

I want to:

  1. Copy a folder from a CD to the users ‘Documents’ folder
  2. Open a Word template in the copied folder
  3. ‘Save as …’ the Word template (Word takes card of where)
  4. Close the template window
  5. Open a Word document in the copied folder

Breaking down the actions (as I think Applescript needs)
Upon User double click of a compiled script on a CD named “Templates” the script will:

  1. Find out where a users ‘Documents’ folder is on their computer
  2. copy a folder “Mac Versions” from the CD into the users ‘Documents’ folder (for OS 9 OR OS X)
  3. open a ‘Template.dot’ that’s in the just copied “Mac Versions” folder (in their ‘Documents’ folder)
  4. ‘Save as …’ 'Template.dot (Word automatically saves it to the users ‘My Templates’ folder
  5. then open 'Document.doc that is in the just copied ‘Mac Versions’ folder
  6. End the script (with the Word document left open)

I have no ide how to deal with finding file path names so I can copy the folder to the right place and open docs from the copied location, so I’ve focused on the word docs. In testing so far (with a folder that’s on my Desktop in OS X)

I have created a script that does the ‘Open Template’ → ‘Save as…’ → ‘Open the word document’:

tell application “Microsoft Word”
open file “MY HD:Users:MY HOME:Desktop:Mac Versions:Templates:Template.dot”
do Visual Basic " ActiveDocument.SaveAs FileName:=“Template.dot”, FileFormat:=wdFormatTemplate"
close document 1 of window 1
open file “MY HD:Users:MY HOME:Desktop:Mac Versions:Document.doc”
end tell

Problem is, it only works if Word is already running. If it’s not, it get’s “broken” by the darned Project Gallery that opens on Word launch by default.

Thing is, normally, if a you double click on a Word file, Word will bypass the Project Gallery and open striaght to the file. THAT’s the behavior I want to implement.

So any help I can get on:

  1. Copying the folder from the CD to a users ‘Documents’ folder
  2. Opening the Template whether Word is running or not

will be greatly appreciated.

Thanks

Lyle

To bypass the project window add an “activate” line to your file opening script:

tell app "Word"
   activate
   open file "Path:to:file:filename.doc"
end tell

As for finding out where user’s documents folders are, see the standard addtion “path to” command

path to documents folder

Sorry, tried activate - made no difference.

Project Gallery still runs and throws a Word error in script editor.

Thanks for the path to documents hint. so I just have to apply that to a variable right ? and use that variable in the ‘open file’’ script?

Remember, said I was a newbie.