![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 10:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com