Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Jan 23, 2013, 06:33 AM   #1
macrumors 6502
Join Date: Mar 2007
Applescript : close word document (office 2011)

i'm simply trying to close a document (without quitting word), but this does not work.

I've tried :

close documents saving no
close active document
close document 1
but none of this is working..

The error I get (on the close line) is:

Microsoft Word got an error: The object you are trying to access does not exist
Here is a simplified script. Anyone have any ideas? All examples online seem to use this syntax, not sure if anything changed in the mac office 2011 version? Or is it just me? Does this code work on your system?

Thanks in advance.

set input to {POSIX path of "/Users/Wesley/Desktop/test.doc"}

tell application "System Events"
if UI elements enabled is false then set UI elements enabled to true
end tell

set pdfSavePath to POSIX path of (choose folder with prompt "Set destination folder")
repeat with x in input
display dialog x

tell application "Microsoft Word"
    open x
    set theActiveDoc to the active document

    close theActiveDoc saving no

    end tell
 end repeat

Last edited by wesleyh; Jan 26, 2013 at 09:26 AM.
wesleyh is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

applescript, ms-office, office

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 08:27 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC