Re: more help with excel, this time renaming an open app
Re: more help with excel, this time renaming an open app
- Subject: Re: more help with excel, this time renaming an open app
- From: David Wignall <email@hidden>
- Date: Wed, 10 Jul 2002 23:16:24 +1200
on 3/1/70 4:28 pm, mike lee at email@hidden wrote:
>
hello all,
G'day Mike. You might want to check your system clock. It believes itself to
be in the seventies ;)
>
code:
>
>
tell application "Microsoft Excel"
>
set currentfile to "A-205-3849-B001.xls"
>
>
Activate Window currentfile
>
Activate Sheet 1
>
set resultname to ((get Value of Cell "R4C12" as string) & "." &
>
(get Value of Cell "R3C12" as string))
>
>
>
Activate Window "bulk.xls"
>
Save Window "bulk.xls" In ("ten:Aero_Results:" & resultname & ":" &
>
resultname & ".bulk.xls") As xlNormal
>
Close Window
>
>
end tell
>
>
because the script returns this message:
>
>
"bulk.xls" does not understand save (or something to that effect)
>
>
i don't even know if the rename is working, let alone the saving.
I suspect that you may have based this code on a recorded example? You don't
need to "Activate Window" at all and in fact this is the base cause of your
problem as a window does not know about saving. Rather, you should refer to
workbooks. For example:
set resultname to Value of Cell "R4C12" of Sheet 1 of Workbook
"A-205-3849-B001.xls" --one line
And
Save Workbook "bulk.xls" In "ten:Aero_Results:" & resultname & ":" &
resultname & ".bulk.xls" -- one line
Except that that last line won't quite work...
>
note: the file is being saved in the folder resultname (its value
>
actually) and i'm also placing the value of resultname to the string
>
".bulk.xls"
...because, I believe, that you can't create a directory in this way. At
least I can't OMM (OS9.1, AS 1.6, XL2001). AFAIK you need the Finder to
create a folder. So you may be after something like this:
tell application "Microsoft Excel"
set currentfile to "A-205-3849-B001.xls"
set resultname to Value of Cell "R4C12" of Sheet 1 of Workbook
currentfile -- one line
end tell
tell application "Finder"
make new folder with properties {name:"ten:Aero_Results:" & resultname}
end tell
tell application "Microsoft Excel"
Save Workbook "bulk.xls" In "ten:Aero_Results:" & resultname & ":" &
resultname & ".bulk.xls" -- one line
end tell
One minor point is that you don't need to explicitly change the cell value
to a string as it will happen as soon as you concatenate resultname
>
i really apologize if this is daft question, im a definite newbie so
>
sometimes basic concepts fly right over my head.
Ahh, mate! Don't be so hard on yourself ;-)
--
hth
Dave
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.