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

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 23, 2013, 06:33 AM   #1
wesleyh
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 :

Code:
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:

Code:
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.

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

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

--RUN THE GUISCRIPT
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"
    activate
    open x
    set theActiveDoc to the active document

    close theActiveDoc saving no

    return
    end tell
 end repeat

Last edited by wesleyh; Jan 26, 2013 at 09:26 AM.
wesleyh is offline   0 Reply With Quote
Old Jan 23, 2013, 04:48 PM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Works on Leopard with Microsoft Office 2004.
Attached Thumbnails
Click image for larger version

Name:	Picture 1.png
Views:	9
Size:	75.6 KB
ID:	392154  
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old Jan 26, 2013, 09:23 AM   #3
wesleyh
Thread Starter
macrumors 6502
 
Join Date: Mar 2007
Thanks, I reinstalled word and now it works. Perhaps I didn't select the automator section of the installation previously.
wesleyh is offline   0 Reply With Quote

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

Tags
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 05:57 AM.

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

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