Applescript to open word doc directly in word

I have hundreds of old word files that I would like to convert to pdf format.
Im running OSX 10.6.8 and Word 2008 (12.3.3).
When I go to open the files in the finder, I get an error from Word that says:
"The file type is blocked from opening in this version. To help secure your computer, some file types are blocked from opening when you double-click the fire or drag the file to the Microsoft Word icon,  If you trust the file is secure, you can open the file by clicking Open on the File menu."
From the official Microsoft support page it says the following:
"Consider the following scenario. In Microsoft Word 2008 for Mac, you try to open a document that was created in an earlier version of Microsoft Word for Mac. To do this, you use one of the following methods:
You double-click the document.
You drag a document to the Word 2008 for Mac program icon.
You drag a document to the Word 2008 for Mac program icon that is in the Dock.
You run an AppleScript that uses the Finder to open a Microsoft Word document.
In this scenario, the document does not open as expected in the Word for Mac program."
When I open the file as suggested (open Word, choose File>Open, select file), it opens.
I created the following applescript, which I though would be the same as using Word to open the file:
set x to choose file
tell application "Microsoft Word"
    activate
    open x
end tell
For some reason, running this script gives me the same error as trying to double click the file in the finder.  Is my syntax in the above script still somehow trying to use the finder to open the file?  Is there anyway to automate this?

Maybe you would like to try the following script. The Word document must be on the desktop though.
set x to choose file default location (path to desktop)
tell application "Finder"
    -- Get the name of the file (without the name extension):
    set theName to name of x
    set P to offset of "." in theName
    set theName to text 1 through (P - 1) of theName
end tell
tell application "Microsoft Word" to activate
tell application "System Events"
    tell process "Microsoft Word"
        keystroke "o" using {command down}
        delay 1
        keystroke "d" using {command down} -- desktop
        keystroke theName & return -- open the file
    end tell
end tell
Message was edited by: Pierre L.

Similar Messages

  • How to open a ".doc" file with ms word directly with this servlet?

    Here is a servlet for opening a word or a excel or a powerpoint or a pdf file,but I don't want the "file download" dialog appear,eg:when i using this servlet to open a word file,i want open the ".doc" file with ms word directly,not in IE or save.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class OpenWord extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request,response);
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
    String strFileName = req.getParameter("filename");
    int len = 0;
    String strFileType1 = "application/msword";
    String strFileType2 = "application/vnd.ms-excel";
    String strFileType3 = "application/vnd.ms-powerpoint";
    String strFileType4 = "application/pdf";
    String strFileType = "";
    if(strFileName != null) {
         len = strFileName.length();
         if(strFileName.substring(len-3,len).equalsIgnoreCase("doc")) {
              strFileType = strFileType1;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("xls")) {
              strFileType = strFileType2;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("ppt")) {
              strFileType = strFileType3;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("pdf")) {
              strFileType = strFileType4;
         } else {
              strFileType = strFileType1;
    if(strFileName != null) {
         ServletOutputStream out = res.getOutputStream();
         res.setContentType(strFileType); // MIME type for word doc
    //if uncomment below sentence,the "file download" dialog will appear twice.
         //res.setHeader("Content-disposition","attachment;filename="+strFileName);
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         String path = "d:\\"; //put a word or a excel file here,eg a.doc
         try {
         File f = new File(path.concat(strFileName));
         FileInputStream fis = new FileInputStream(f);
         bis = new BufferedInputStream(fis);
         bos = new BufferedOutputStream(out);
         byte[] buff = new byte[2048];
         int bytesRead;
         while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
         bos.write(buff, 0, bytesRead);
         } catch(NullPointerException e) {
         System.out.println ( "NullPointerException." );
         throw e;
         } catch(FileNotFoundException e) {
         System.out.println ( "FileNotFoundException." );
         throw e;
         } catch(final IOException e) {
         System.out.println ( "IOException." );
         throw e;
         } finally {
         if (bis != null)
         bis.close();
         if (bos != null)
         bos.close();

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

  • Why can't I open word docs from mail anymore?

    Am on 10.8.2 on Macbook Air and doc and docx attachments tell me to choose application to open the doc with and won't open when I choose "Word"
    These used to be opened automatically by Word, not I have to manually choose Pages as the only option
    Am I missing something?

    Csound1 wrote:
    Andy Mt P wrote:
    Don't see how I can choose the file from within Word as it's not saved anywhere?
    I have now discovered if I drag the file from mail on to the WORD icon in the doc it will open....seems much clumsier than the old option of clicking on the file to open it
    Opening attached pics seems to require the same action as well using iphoto.
    A bit of a step back in my opinion....
    Save the word file from the email to your Mac (have you never saved an attachment before)?
    Post back when you can do as I asked you to.
    And remember that we are trying to find out what is wrong, don't be so snappy!
    haha...point taken. Wasn't feeling 'snappy' when I typed it, not intended as such...!
    If I save it somewhere as you suggested I can then open it
    also, as I mentioned if I drag the doc onto WORD in the dock it opens that way as well

  • Can you open word doc. In pages? (Opening a doc. From the web) in the iPad or iPod tuch?

    Can you open word doc. In pages? (Opening a doc. From the web) in the iPad or iPod tuch?

    NH,
    This may seem a fine point, but iWork apps don't actually Open Office apps. They Import them. The reason I make this distinction for you is that when you view the result of the import, you may see some variations from what was in the Office document because of an imperfect translation, and when you make edits, you are editing an iWork document, not the original Office document.
    Jerry

  • I have a brand new macbook pro 15" with latest Lion.Can anyone tell me why, when I open word or preview etc that multiple files open?For eg if I open a word doc, the last 1-3 docs that I have worked on all open. why?

    I have a brand new macbook pro 15" with latest Lion. Can anyone tell me why, when I open word or preview etc that multiple files open?For eg if I open a word doc, the last 1-3 docs that I have worked previously on all open. Can anyone tell me why?

    You have a choice as to whether or not applications in Lion like Word or Preview (or even Safari) save and re-open previous documents or windows... just hold down the option key while quitting a program and when you re-open it you won't get the previous documents or windows when you re-open the application. You can see this by selecting the open program in the menu bar and when holding down the option key the quit function will change to quit and discard open windows. This feature in Lion is referred to as "Resume" and is great if you want to restart an app and return to what you're doing (for example in Safari re-opening existing windows and tabs from your previous session). You still have the option to close individual windows within an app before quitting and they will not re-open when the app is launched again.
    This Resume function is not related to saving your work (a word or text document for example). This is handled by Lion's "Auto-Save" and "Versions" functions. See http://www.apple.com/ca/macosx/whats-new/auto-save.html
    Hopefully this is the complete answer you're looking for.

  • Error Message when opening attached doc  with Mac for Word 2008

    When I try to open attached docs of any any sorts (mainly word/pdf) I get an error message that wont allow me to open the attachments, please help!!
    I have MB Pro with Mountain Lion

    There are some things I can open but word docs and pdf docks I cannot open, here's the error

  • I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after saving as from word 2007 - I uninstalled Pro X1 and now when I save as from word 2007 to PDF it will

    Can anyone help with this - do I have to uninstall Reader and then reinstall?

    I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after "saving as" from word 2007 - I uninstalled Pro X1 and now when I "save as" PDF from word 2007 to PDF it will save the document as a PDF but will not open the document to display after publishing - I have to got to where the file has been saved to view the new PDF document - this is really annoying - do I have to delete adobe reader and reinstall it - adobe needs to look at this conflict with acrobat pro as I have even gone it to properties and tried to have adobe reader as the default PDF program - the main issue is that I cannot view the PDF after publishing it from word 2007

  • Can't open Word .doc in lion

    I installed OS Lion yesterday.  I cannot open any Word documents saved .doc.  I can open docx files.  What do I do?

    TextEdit found in your Applications folder will open Word documents. I have the same problem. come on Apple try sort it out

  • Can't open Word .doc in Pages

    I have Pages 5.1 and it won't open MS Word document (97-2004). I created the .doc documents in Appleworks. When Appleworks was replaced by Pages, my wife was left with a lot of .ckw files that could be accessed. I pulled out an old MBP and went back to TimeMachine backup and restored Appleworks, opened the .ckw files and saved them as Word documents with the goal of getting them into Pages. No luck so far. Originally Pages opened Word documents and you could save a document as as Word. Has something changed?

    I'll also add that this "learning experience" has solved another issue that my wife had..."missing files". My wife has been complaining recently that her Pages files are disappearing. I would just shake my head and say that she was crazy. Now, I understand. Pages is now "beta" testing the iCloud storage of Pages documents. So, when she would save her Pages documents and quit Pages, her natural assupmption was that they were saved to her Documents Folder but they were actually saved to iCloud. Her normal routine is to go to Finder and go to Documents and look for a document she had created, and it wouldn't be there. Pages expects you to go to "Recent Documents" look either in iCloud or On My Mac.
    I just played with it (I have Pages on my MBA and iPad and iPhone) and while I think Apple is on the right track with iCloud storage, I don't like the difficult process of "Moving" a document in order to get it to my Mac. I think it should be a simple choice of choosing where you want to save your document - iCloud or my Mac or a drive connected to my Mac.

  • Downloaded Adobe 9 -- Using Word 2007 to open PDF doc (Error Msg)

    I just updated to Adobe 9 and am getting this signature error message when trying to open a pdf doc from MicroSoft Word 2007:  appname: acrord32.exe appver: 9.3.0.148 ModName: acrord32dll ModVer: 9.3.0.148 Offset: 001937fa
    Am not able to get beyond the error msg. 
    Help anyone?

    I have MicroSoft Word Office 2007.
    I recently upgraded from Adobe 8.1 to 9.3.  Now, I can no longer open pdf docs.
    I am getting an error that says: "Adobe Reader 9.3 (or 8.1) has encountered a problem and needs to close."
    I have uninstalled 9.3 and reinstalled.  I have uninstalled 9.3 and reinstalled 8.1.  I have gone back to 9.3.
    I have run 2008 Advanced Registry Optimizer.
    The error signature when trying to open a pdf file w/ either Adobe Reader (9.3 or 8.1) is this:
    AppName acrord exe AppVer: 9.3.0148 ModName: acrord32.dll ModVer: 9.3.0.148 Offset: 0019371a.
    How do I get back to opening pdf docs??

  • How can I open Word docs with Pages?

    I just installed the iWorks software because it said it would open Word docs. Now I can't seem to open any Word .doc files I had archived onto CDs, after abandoning my PC.
    I've made Pages my default application for opening text, and that didn't help. I just keep getting the error message "The document "X.doc" couldn't be opened." Any ideas?
    IMAC   Mac OS X (10.4.8)  

    Welcome to Apple Discussions Paul
    Pages - the word processing/page layout application in iWork (no "s") - usually doesn't have any problems with opening Word files, but I do believe it can't open any Word files older than version 6. It is also highly unlikely that it would be able to open any from the new 2007 version. If your documents are from a version in between those, they should open.
    How are you trying to open them? There are at least three common methods, but, since you say the documents are on a CD, I suggest copying them from the CD to your hard drive first. To open one at a time you can use File > Open (where > means following menu commands with your cursor). To open more than one at a time, select the ones you want by Command- (⌘) clicking the files & then dragging them onto the Pages icon in the Dock or a Finder window or Control- or right-click & choose Pages from Open with in the contextual menu that appears.

  • Can't open Word docs with Pages 08

    Since upgrading to SL I found that I can no longer open Word documents sent to me via email attachments. Can this be remedied? I thought Macs were able to "translate" Word files.
    Help!

    I did discover I can open Word docs with Text Edit, but it's a multi-step process now. I really don't want to upgrade to iWork 09 and I'm not sure that would solve the problem. I also have to use Quick Time now to open movies in iPhoto. Another multi-step process. I'm not very happy with SL.

  • Open Word docs with the new Pages?

    Pages does not open. I had the new one installed but apparently had the old one still up. How can I open Word docs with the new Pages?

    Pages 5 is in your Applications folder.
    Pages '09/'08 is in your Applications/iWork folder.
    You are alternately opening the wrong versions.
    Pages '09/'08 can not open Pages 5 files and you will get the warning that you need a newer version.
    Pages 5.01 can not open Pages 5.1 files and you will get the warning that you need a newer version.
    Pages 5 can open Pages '09 files but may damage/alter them. It can not open Pages '08 files at all.
    Once opened and saved in Pages 5 the Pages '09 files can not be opened in Pages '09.
    Once opened and saved in Pages 5.1 files can not be opened in Pages 5.
    Anything that is saved to iCloud is also converted to Pages 5 files.
    All Pages files no matter what version and incompatibility have the same extension .pages.
    Pages 5 files are now only compatible with themselves on a very restricted set of hardware, software and Operating Systems and will not transfer correctly on any other server software than iCloud.
    Apple has removed over 95 features from Pages 5 and added many bugs:
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Archive/trash Pages 5, after exporting all Pages 5 files to Pages '09 or Word .docx, and rate/review it in the App Store, then get back to work.
    Peter

  • Help - Can't open Word for Windows docs because of "Spelling Checker" error

    Since updating to the new Pages of iWork 08, I've started having consistent problems opening Word documents sent to me from Windows using colleagues. When I open the .doc in Pages, an error message appears saying "Alert: Couldn't contact Spell Checker." When I dismiss the error message, it immediately pops up again. It is impossible to dismiss the error message long enough to close the document or even to quit Pages, so I have to Force Quit Pages. Can anyone tell me how to fix this problem and be able to open Word documents in Pages again? Thanks!

    WordService is not a spell checker. It adds various actions to the Services menu, such as changing to smart quotes, changing to lowercase, etc. I've been using it successfully since Pages 1 came out.
    I suggest deleting/moving/archiving/something with that CocoAspell file & restart your Mac. It very welll could be the culprit. It's not the current version of these third-party spell checkers that are a problem. The problem seems to be left over bits after a spell checker is removed that is seen when you open a Word document, but the original program isn't found.

  • Opening word docs in pages

    Hi
    I have just upgraded from an 8 year old imac to a brand new one, and have decided to use pages, instead of Office for mac which I used previously on the old mac, but I am have great difficulty in opening word docs in pages.
    I have selected a .doc, gone to get info,then open with, pages( default ), then change all, then try to open a word doc, which results in, unable to open.
    I must be doing something wrong, hence I would be grateful for any assistance.
    Many Thanks

    You need to uninstall the iWork trial. Read second post  on this link http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=105&highlight=reinst all&mforum=iworktipsntrick

Maybe you are looking for

  • GarageBand 08 not working on PowerPC

    Hi, I have a refurbished G4 iBook with PowerPC that I purchased online and GarageBand has never worked properly on my iBook. The OS is Leopard 10.5.8 and GarageBand is 4.1.2. I downloaded the 4.1.2 update and reinstalled it (already had it) just to c

  • How to restrict  tcode va01/va02/va03 for a particular role

    hi , I have a requirement . I need to restric user fro VA01/VA02/VA03 if the user has role and Sales order customer group is related to a particular group . Do we have a Function module to get a role for a user  or can we write a code as authorizatio

  • Trouble updating ipod

    My ipod will not update any new songs from itunes, manually or automatically. The problem started recently after the apple store retored it due to a battery issue...(which still exists). I plugged it back into the computer, and it downloaded all of t

  • Why is my volume icon grey and can't hear through speakers?

    This is what my voleme level looks like, very weird. Does work with headphones but not through the speakers.

  • Probelem When Deleting Files

    v 2.3; Windows XP I have been using LR since original beta and this is the first time this is occurring.  When I delete, the file deletes but still appears in LR with ? indicating lost file, but most disturbingly, LR stops responding.  I know how to