Calling a worksheet via a codename

  • Thread starter Thierry Paradis
  • Start date
T

Thierry Paradis

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.
 
T

Tom Ogilvy

just use xlThesheet

it only works with the activeworkbook.

demo'd from the immediate window:

? xlsThesheet.Name
Sheet1
 
T

Tom Ogilvy

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
 

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