AutoHotkey Community

It is currently May 27th, 2012, 8:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: renaming / adding tabs
PostPosted: February 4th, 2012, 5:48 am 
i was wondering how i could make my autohot key Add two tabs to a New Workbook and then I wanted to loop through all 5 tabs and rename them. I am using M$ Excel 2007.
thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2012, 8:32 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
; requires AutoHotkey_L

XL := ComObjCreate("Excel.Application")
XL.Workbooks.Add
XL.Visible := true

XL.Sheets.Add(ComObj(), ComObj(), 2)
for Sheet in XL.Sheets
   Sheet.name := A_Index

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2012, 3:07 pm 
Thank you Jethrow it worked perfectly!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2012, 3:58 pm 
jethrow wrote:
Code:
; requires AutoHotkey_L

XL := ComObjCreate("Excel.Application")
XL.Workbooks.Add
XL.Visible := true

XL.Sheets.Add(ComObj(), ComObj(), 2)
for Sheet in XL.Sheets
   Sheet.name := A_Index


this added and named the tabs sequentially = 1, 2, 3, 4, 5

Can I put the tab names into an array instead to rename them:
Red, Orange, Yellow, Green, Blue

rather than just a sequence of Numbers?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2012, 4:09 pm 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
Code:
colors := ["Red", "Orange", "Yellow", "Green", "Blue"]
for Sheet in XL.Sheets
   Sheet.name := colors[A_Index]

_________________
Win7 - Firefox 10.0.2 - AHK_L 1.1.07.00
Please bear with me and my English which is so bad at times that even I don't understand myself


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, hyper_, immunity, migz99, sjc1000 and 73 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group