Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 8
Default Calling a worksheet via a codename

Hi!

I have a xla and a xlt. In a xla macro, i need to access a sheet of an
instance of the template with a specific codename. The following code
returns an error:

ActiveWorkbook.xlsTheSheet

even:

ActiveWorkbook.worksheets(xlsTheSheet)

What's the good way to acces the xlsTheSheet?

Thanks,

Thierry Paradis.


  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 27,285
Default Calling a worksheet via a codename

just use xlThesheet

it only works with the activeworkbook.

demo'd from the immediate window:

? xlsThesheet.Name
Sheet1

--
Regards,
Tom Ogilvy


"Thierry Paradis" wrote in message
...
Hi!

I have a xla and a xlt. In a xla macro, i need to access a sheet of an
instance of the template with a specific codename. The following code
returns an error:

ActiveWorkbook.xlsTheSheet

even:

ActiveWorkbook.worksheets(xlsTheSheet)

What's the good way to acces the xlsTheSheet?

Thanks,

Thierry Paradis.




  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 27,285
Default Calling a worksheet via a codename

Another way might be to get a reference to the sheet using the codename,
then use that reference

Sub abc()
Dim sh As Worksheet, s As String
s = ActiveWorkbook.VBProject.VBComponents( _
"xlsTheSheet").Properties("name").Value
Set sh = Worksheets(s)
msgbox sh.Name
End Sub


--
Regards,
Tom Ogilvy


"Thierry Paradis" wrote in message
...
Hi!

I have a xla and a xlt. In a xla macro, i need to access a sheet of an
instance of the template with a specific codename. The following code
returns an error:

ActiveWorkbook.xlsTheSheet

even:

ActiveWorkbook.worksheets(xlsTheSheet)

What's the good way to acces the xlsTheSheet?

Thanks,

Thierry Paradis.




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
Changeing codename of worksheet via VBComponents collection Arne Excel Programming 3 July 13th 05 12:13 PM
Referencing worksheet CODENAME in a chart object. Bing Excel Discussion (Misc queries) 1 February 15th 05 01:01 AM
Some worksheet returns NULL for CodeName property. Why? Shigeo Morita Excel Programming 4 December 3rd 04 11:09 PM
Using Worksheet Codename to Determine Worksheet Existence David Copp[_3_] Excel Programming 4 July 2nd 04 08:00 AM
Worksheet codename Andy Excel Programming 4 December 2nd 03 04:12 PM


All times are GMT +1. The time now is 10:15 PM.

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

About Us

"It's about Microsoft Excel"