Closing windows ...

Hi,

I realized that when Backup executes it does not backup files that are open even if they are automaticaly saved by Excel or Word. I want to create a script that closes and saves all windows of certain open applications.

I did a little script to see what happens with Excel and Word having 4 windows open. The script seems to excute Ok with Word, but with Excel only 1 or 2 window closes.

Does somebody understand what is going wrong. Here is the script:

tell application "System Events"
	tell application "Finder"
		tell application "System Events" to exists process "Excel"
		if result then
			try
				with timeout of 5 seconds
					tell application "Excel" to close every window saving yes
				end timeout
			end try
		end if
	end tell
end tell

Thanks in advance.

Robert

Model: iMac G5 1.6 Ghz
Browser: Safari 523.12.2
Operating System: Mac OS X (10.5)

(Insert witty remark about Office here. :rolleyes:)

I don’t know what the cause is, but I can give you some alternative scripts (the first one requires Leopard):

try
	tell application "Microsoft Excel" to if it is running then
		repeat while (count windows) > 0
			close every window saving yes
		end repeat
	end if
end try
try
	tell application "System Events" to exists process "Excel"
	
	if result then
		tell application "Microsoft Excel"
			repeat while (count windows) > 0
				close every window saving yes
			end repeat
		end tell
	end if
end try