Jon Nathan provided this really good script to do auto save-as on a bunch on documents in Word. I need the same thing done in Excel, to do a save-as (so that the version is updated to the current version of Excel vX). I figured I could tweak myself, but I keep getting a compile error. :oops: Basically I had changed over the Word refs to Excel and the Excel file format to xlNormal.
Anyway, here is the original script which does exactly what I need but in Word. Anyone with a minute to spare, your help will be greatly appreciated.
on run
open (choose folder with prompt “Where are your old Word files?”)
end run
on open the_folder
if class of the_folder = list then set the_folder to item 1 of the_folder
set the_folder to the_folder as string
set target_folder to (my make_target_folder((text 1 thru -2 of the_folder) & “_converted”)) as string
set the_files to (my get_folder_list(the_folder, “doc”))
repeat with i from 1 to count of the_files
copy (my get_name_and_container(item i of the_files)) to {file_name, source_folder}
my convert_file(source_folder, target_folder, file_name)
end repeat
activate
display dialog “Your Word files have been converted.” buttons {“OK”} default button 1 with icon 1 giving up after 10
end open
on convert_file(source_folder, target_folder, file_name)
tell application “Microsoft Word”
activate
open (source_folder & file_name) as alias
do Visual Basic “ChangeFileOpenDirectory “” & target_folder & “””
do Visual Basic “ActiveDocument.SaveAs FileName:=”" & file_name & “”, FileFormat:=wdFormatDocument"
close document 1 of window 1
end tell
end convert_file
on make_target_folder(folder_path)
tell application “Finder”
try
set target_folder to folder_path as alias
on error
copy (my get_name_and_container(folder_path)) to {item_name, container_name}
set target_folder to make new folder at (container_name as alias) with properties {name:item_name}
end try
end tell
return target_folder
end make_target_folder
on get_name_and_container(item_path)
set item_path to item_path as string
my atid(“:”)
set item_name to text item -1 of item_path
set item_count to ((count of text items of item_path) - 1)
set container_name to “”
repeat with i from 1 to item_count
set container_name to container_name & text item i of item_path & “:”
end repeat
my atid(“”)
return {item_name, container_name}
end get_name_and_container
on get_folder_list(the_folder, file_extension)
set the_files to {}
tell application “Finder” to set folder_list to every file of folder the_folder whose name ends with file_extension
repeat with new_file in folder_list
copy (new_file as string) to end of the_files
end repeat
return the_files
end get_folder_list
on atid(the_delim)
set AppleScript’s text item delimiters to the_delim
end atid
–this script was automatically tagged for
–color coded syntax by Script to Markup Code
–written by Jon Nathan