dear apple freinds ,
i am developing an apple script in which some excel sheets of source files has to be copied to the target file . I am not getting the right syntax how to copy the sheet from the source file to target file . the source file is big (48 MB) and having near about 125 sheets , in which near about 60 sheets has to be copied to target file .
best regards
krishna
The workflow and sysntax is as follows :
property source_sheets : {"000008_041003", "000007_040929", "000014_041017"}
set source_file to (choose file) as string
set target_file to (choose file) as string
tell application "Microsoft Excel"
activate
set source_file_name to source_file as string
open workbook workbook file name source_file_name
set target_file_name to target_file as string
open workbook workbook file name target_file_name
--copying the sheets from source file to target file
repeat with copy_sheet in source_sheets
activate next window 1
activate object worksheet copy_sheet
(* the part for which sysntax is required
copy worksheet sheet copy_sheet in workbook target_file_name
*)
activate next window 1
end repeat
end tell
If all else fails, GUI script it. System Events and Extra Suites are my best friends.
EDIT: I actually threw together a script in like 30 minutes a few weeks back to convert .rtf files and .html to plain text and then combine about 200 text files into one giant text file. Before you ask, I wanted to search my entire conversation history with someone because I wanted to see how many times things were said due to bored. >.< The entire process was done in System Events since I just needed something quick I was probably only going to use once, which sounds like what you need.
EDIT2: Ok I figure if anything you can modify my script since I would think we’re doing nearly the same thing. I’m not very familiar with Excel, but I would think you can do select all and copy so hopefully this is up your alley. Heh btw, I don’t have the conversion part anymore. I didn’t save it. >.<
set filePath to choose file with prompt "Choose file(s) to expand" with multiple selections allowed without invisibles
set x to 1
set fileNum to item x of filePath
activate application "TextEdit"
repeat until exists window 1 of application "TextEdit"
delay 0.5
end repeat
tell application "System Events"
keystroke "n" using command down
repeat
tell process "textedit"
open fileNum
end tell
delay 3
repeat until exists window 1 of process "textedit"
delay 0.5
end repeat
keystroke "a" using command down
delay 0.5
keystroke "c" using command down
delay 0.5
keystroke "w" using command down
delay 0.5
keystroke "v" using command down
delay 0.5
keystroke return
delay 0.5
set x to x + 1
set fileNum to item x of filePath
end repeat
end tell
property source_sheets : {"000008_041003", "000007_040929", "000014_041017"}
set source_file to (choose file) as string
set target_file to (choose file) as string
tell application "Microsoft Excel"
activate
set sourceBook to open workbook workbook file name source_file
set targetBook to open workbook workbook file name target_file
repeat with copy_sheet in source_sheets
copy worksheet sheet copy_sheet of sourceBook after last sheet of targetBook
end repeat
end tell
PS: Sk8, your script can also be done without any dreadful GUI scripting
TextEdit’s dictionary isn’t very rich, but sufficient
set filePath to choose file with prompt "Choose file(s) to expand" with multiple selections allowed without invisibles
tell application "TextEdit"
activate
set newDoc to make new document
repeat with oneFile in filePath
open oneFile
set theText to text of front document
close front document
tell newDoc
set its text to (get its text & theText & return & return)
end tell
end repeat
end tell