Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ozz Ozz is offline
external usenet poster
 
Posts: 6
Default how to use codenames with an addin?

I´m writing my first addin and I´m having the following problem:

I have a workbook which retrieves data from a database. With the addin I
create a new menu that has the update functions. One update function should
be renaming 6 sheets in the workbook. Of course, once renamed, the sheets
have a different name the next time I use the update, so I want to use the
codename of the sheets as the reference. But I read somewhere that I can´t
use codenames to reference to sheets in a different workbook, hence it
wouldn´t work from the addin either.

Is there a solution or workaround to this problem?
Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default how to use codenames with an addin?

Dim wb As Workbook
Dim ws As Worksheet
Dim sCodename As String
Dim n As Long

Set wb = Application.Workbooks("myFile.xls")

sCodename = "myCodename" ' case sensitive

For Each ws In wb.Worksheets
n = n + 1
If ws.CodeName = sCodename Then
Exit For
End If
Next

If n wb.Worksheets.Count Then
MsgBox "not found"
Else
MsgBox ws.Name, , "ws no. " & n
End If

Bear in mind there are problems returning the codename of a new sheet that's
been inserted with the VBE closed and the file not saved.

Regards,
Peter T


"Ozz" wrote in message
...
I´m writing my first addin and I´m having the following problem:

I have a workbook which retrieves data from a database. With the addin I
create a new menu that has the update functions. One update function

should
be renaming 6 sheets in the workbook. Of course, once renamed, the sheets
have a different name the next time I use the update, so I want to use the
codename of the sheets as the reference. But I read somewhere that I can´t
use codenames to reference to sheets in a different workbook, hence it
wouldn´t work from the addin either.

Is there a solution or workaround to this problem?
Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loops with sheet codenames NEMB Excel Discussion (Misc queries) 0 February 13th 11 12:34 AM
using variables in codenames [email protected] Excel Programming 1 April 28th 06 11:30 PM
Excel Worksheet Codenames 2 Alasdair Stirling[_2_] Excel Programming 4 November 1st 04 03:46 PM
Using worksheet codenames dan Excel Programming 0 January 22nd 04 09:46 PM
From my Addin, referring to activeworkbook's sheets by their codenames Dianne Excel Programming 5 August 27th 03 04:36 PM


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"