LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Class Modules - referring to workbook properties

I need some assistance from someone who is knows about Class Modules please.
I'm trying to set up some Class Mods so that I can refer to a
Workbook/Sheet/Range using a variety of the properties. So far I have the
following in a class module called CTLS:

Option Explicit
Private pTLS As Workbook
Private Sub Init()
Set pTLS = Workbooks("1. TOOLS.xls")
End Sub

Public Property Get TLS() As Workbook
Attribute TT.VB_UserMemId = 0 'THIS LINE IS NOT VISIBLE in VBE
If pTLS Is Nothing Then Init
Set TLS = pTLS
End Property

Public Property Get Sheets() As Excel.Sheets
Set Sheets = pTLS.Sheets
End Property

Public Property Get Name() As String
Name = pTLS.Name
End Property

Private Sub Class_Initialize()
Init
End Sub

Private Sub Class_Terminate()
Set pTLS = Nothing
End Sub

and in a normal module I have
Option Explicit
Public TLS As New CTLS
Public TT As New CTT

The next Class Module is CTT:

Option Explicit
Private pTT As Worksheet
Private Sub Init()
Set pTT = Workbooks("1. TOOLS.xls").Worksheets("TOOLS")
End Sub
Public Property Get TT() As Worksheet
If pTT Is Nothing Then Init
Set TT = pTT
End Property
Private Sub Class_Initialize()
Init
End Sub
Private Sub Class_Terminate()
Set pTT = Nothing
End Sub

So, with this I can type into the Immed Window
? TLS.Name
1. TOOLS.xls
? TLS.sheets("TOOLS").name
TOOLS

and get the correct results as shown there.

What I can't figure out (and I've read Chip's site and read Walkenbach's
chapters) is how to do some other things such as
TLS.save
TLS.activate
TT.activate (TT is a sheet)
TT.select
TT.visible = false etc etc

In particular I need to be able to refer to ANY range in TT, which I imagine
will need another Class Mod called (say) CTrng (C for class, T for TOOLS). I
need to be able to do any of the usual things that we do with ranges.

For the record, the Attribute statement was added via Notepad, and then the
class module imported from the notepad, so that auto-instancing is set up.
Therefore the values of TLS and TT are always refreshed when they are needed.

From this point I am completely stuck. Class Modules are not the easiest
things to wrap my head around, and any assistance will be greatly
appreciated. Regards, Brett.

 
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
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
Class Modules Pavlos Excel Programming 5 January 19th 05 05:31 PM
Class Modules ibeetb Excel Programming 1 January 5th 04 10:04 PM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM


All times are GMT +1. The time now is 03:26 PM.

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"