Renaming sheet tabs with input Prompt box

G

gumbah5

Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi,

Just "discovered" the wonderful world of Applescript! I'm attempting to have the input from a prompt box enter into a specified cell and then populate another sheet as well as change the name of that sheet's tab. I'm able to open the correct worksheet and bring up the necessary sheet. I can also get the prompt box to come up...I then want whatever name is inputted to replace cell "A2"...which would then change the student name on the first student sheet (through an existing simple excel reference)...as well as change the tab of the first student sheet...I'll keep searching but if anyone has a suggestion, I'm all ears! Thanks!

here's what I've assembled so far:

tell application "Microsoft Excel"
        try open workbook workbook file name "test.xls"
        activate sheet "list"
        set myRange to range "A2:A11" of worksheet "Sheet1"range "A2"
        input box prompt "Please replace provided text with a Student Name" title "Students"
        set result to "A2"
        end try
end tell
 
J

JE McGimpsey

Version: 2008
Operating System: Mac OS X 10.6 (Snow Leopard)
Processor: Intel

Hi, <br><br>Just &quot;discovered&quot; the wonderful world of Applescript!
I'm attempting to have the input from a prompt box enter into a specified
cell and then populate another sheet as well as change the name of that
sheet's tab. I'm able to open the correct worksheet and bring up the
necessary sheet. I can also get the prompt box to come up...I then want
whatever name is inputted to replace cell &quot;A2&quot;...which would then
change the student name on the first student sheet (through an existing
simple excel reference)...as well as change the tab of the first student
sheet...I'll keep searching but if anyone has a suggestion, I'm all ears!

Perhaps something like:

tell application "Microsoft Excel"
try
open workbook workbook file name "test.xlsx"
set myRange to range "A2" of worksheet "list"
set myName to input box prompt ¬
"Please replace provided text with a Student Name" title "Students"
set value of myRange to myName
set name of sheet 2 to myName
end try
end tell
 
G

gumbah5

> (e-mail address removed) wrote:
>
> > Version: 2008
> > Operating System: Mac OS X 10.6 (Snow Leopard)
> > Processor: Intel
> >
> > Hi, Just &quot;discovered&quot; the wonderful world of Applescript!
> > I'm attempting to have the input from a prompt box enter into a specified
> > cell and then populate another sheet as well as change the name of that
> > sheet's tab. I'm able to open the correct worksheet and bring up the
> > necessary sheet. I can also get the prompt box to come up...I then want
> > whatever name is inputted to replace cell &quot;A2&quot;...which would then
> > change the student name on the first student sheet (through an existing
> > simple excel reference)...as well as change the tab of the first student
> > sheet...I'll keep searching but if anyone has a suggestion, I'm all ears!
>
> Perhaps something like:
>
> tell application &quot;Microsoft Excel&quot;
> try
> open workbook workbook file name &quot;test.xlsx&quot;
> set myRange to range &quot;A2&quot; of worksheet &quot;list&quot;
> set myName to input box prompt &amp;#65533;
> &quot;Please replace provided text with a Student Name&quot; title &quot;Students&quot;
> set value of myRange to myName
> set name of sheet 2 to myName
> end try
> end tell
> [/QUOTE]

Thanks Mr. McGimpsey! Here's what I came up with:

tell application &quot;Microsoft Excel&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;open workbook workbook file name &quot;test.xls&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;activate object worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A2&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 3 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A3&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 4 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A4&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 5 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A5&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 6 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A6&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 7 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A7&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 8 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A8&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 9 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A9&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 10 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A10&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 11 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myRange to range &quot;A11&quot; of worksheet &quot;names&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set myName to input box prompt &quot;Please type a Student Name&quot; title &quot;Students&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set value of myRange to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set name of sheet 12 to myName
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end try
end tell

1) How do you put in this little guy &quot;¬&quot; so the whole script shows up correctly in the forum?
2) I would need to send the .xls file in question along with the script, yes? (they all have excel) If they place the script on the desktop, that would be okay?
3) when the script runs, Excel opens the file but then sends it to the dock where it bounces...surely there is a way to keep the application open?
4) This won't help any PC Excel users?
5) Again, thanks for the guidance! I truly appreciate it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top