Re: Saving in Excel 2008
Re: Saving in Excel 2008
- Subject: Re: Saving in Excel 2008
- From: Deivy Petrescu <email@hidden>
- Date: Thu, 12 Feb 2009 13:25:45 -0500
First off, thanks Shane, Stan and Steve or as you are commonly known
the 3S. Much, much ahead of 3M!
I am at work now and I can test the scripts in 2008.
Following Shane's suggestion I saved all or almost all scripts I ran.
Here is what I've got.
These scripts do not save the files, and to add insult to injury they
prompt the user to be saved.
---- does not work ---
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook active workbook in ("" & (path to "desk") & "test" &
l & ".xls") ¬
as workbook normal file format
close active workbook saving "no"
end repeat
on error e
display dialog e
end try
end tell
---- does not work ---
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook workbook 1 in ("" & (path to "desk") & "test" & l &
".xls") ¬
as workbook normal file format
close workbook 1 saving "no"
end repeat
on error e
display dialog e
end try
end tell
---- does not work ---
set ptdt to ("" & (path to "desk") & "test")
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook active workbook in ptdt & l & ¬
".xls" as workbook normal file format
close active workbook saving "no"
end repeat
on error e
display dialog e
end try
end tell
---
---- These scripts do save the files. In other words these script work
as expected.
---- These scripts do not prompt the user to be saved
--- works ---- works ---- works ---- works ---- works ----
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook as active workbook filename ("" & (path to "desk") &
"test" & l & ".xls")
close active workbook saving "no"
end repeat
on error e
display dialog e
end try
end tell
--- works ---- works ---- works ---- works ---- works ----
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook as workbook 1 filename ("" & (path to "desk") &
"test" & l & ".xls")
close workbook 1 saving "no"
end repeat
on error e
display dialog e
end try
end tell
--- works ---- works ---- works ---- works ---- works ----
set ptdt to ("" & (path to "desk") & "test")
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save active workbook in (ptdt & l & ".xls") as workbook normal file
format
close active workbook saving "no"
end repeat
on error e
display dialog e
end try
end tell
--- works ---- works ---- works ---- works ---- works ----
set ptdt to ("" & (path to "desk") & "test")
tell application "Microsoft Excel"
activate
try
close workbook 1
end try
try
repeat with j from 1 to 3
make new workbook at front
tell active workbook
select sheet 1
tell sheet 1
set its name to "Attendance " & j
set value of cell "A1" to "Last Name " & j
set value of cell "B1" to "First Name " & j
set value of cell "C1" to "Student ID " & j
end tell
end tell
end repeat
repeat with l from 1 to (count of workbooks)
save workbook 1 in (ptdt & l & ".xls") as workbook normal file format
close workbook 1 saving "no"
end repeat
on error e
display dialog e
end try
end tell
---------
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden