Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default How to extend a standard class (like Worksheet)

Hi to all,

After I tried to implement by myself ... I realize that is
a bit of more complicated so I ask anyone who knows how to
do'it just to tell me:
How can be implemented a subclass of a built-in class like
Worksheet, if it can be? This, in order to add new events,
for example!

Thanks in advance
Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default How to extend a standard class (like Worksheet)

Have you tried creating a new Class and making
Worksheet one of its properties? E.g., with code
such as follows in the Class Module:

Private m_WS As Worksheet

Public Property Let WS(ByVal vData As Worksheet)
Set m_WS = vData
End Property

Public Property Get WS() As Worksheet
Set WS = m_WS
End Property

HTH,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default How to extend a standard class (like Worksheet)

Hi Merjet,
No, I didn't try to do this.
As it seems to me, this won't be a real extension (e.g.
adding new events and properties to a class). You get only
access to an object of Worksheet type. What I want to do
is to add mouse events to the Worksheet class. But, again,
maybe I'm wrong.
I've tried to use "implements ..." with Sheet1 object, but
I've got stuck to the definition of "_CodeName" property,
which I don't know how to do it. VBA gets me "Character
not valid" for "_".

Thanks anyway for help.
mike

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default How to extend a standard class (like Worksheet)

Hi Mike,

No, I didn't try to do this.
As it seems to me, this won't be a real extension (e.g.
adding new events and properties to a class). You get only
access to an object of Worksheet type. What I want to do
is to add mouse events to the Worksheet class. But, again,
maybe I'm wrong.


What I suggested trying was only a start. You could add
any other properties or methods you want to the Class.

HTH,
Merjet


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default How to extend a standard class (like Worksheet)

"mike" wrote ...

As it seems to me, this won't be a real extension (e.g.
adding new events and properties to a class).


You can add Public (or Friend) properties and methods to the Sheet1
code module e.g.

Public Property Get MyProperty() As String
MyProperty = "Blah"
End Property

You can even add and raise a public event in the Sheet1 code module
(but who sees it?)

It seems to have a hidden line:

Private WithEvents Worksheet As AMuchMoreComplexAnimal

Elsewhere, there seems to be a single Sheet1 object variable. You can
call e.g. the property added above wherever this object variable is in
scope.

Sheet1 is a bit like UserForm1 in that it of type UserForm but also a
class in its own right i.e. you can add custom properties, methods and
events. Unlike UserForm1, however, you can't create an instance of
Sheet1:

Dim oSheet1 As Sheet1
Set oSheet1 As New Sheet1

The second line (note *only* the second line) gives a compile error.
So its instancing type must be GlobalMultiUse. But it has no
Initialize nor Terminate event, so it isn't even a class.

So what is Sheet1? It's not a Worksheet, because this fails:

Public Function SayBlah(ByVal oSheet As Worksheet)
MsgBox oSheet.MyProp
End Function

But change to:

Public Function SayBlah(ByVal oSheet As Object)
MsgBox oSheet.MyProperty
MsgBox TypeName(oSheet)
End Function

Public Sub test()
SayBlah Sheet1
End Sub

And this time it works. But now it says the object type is Worksheet!

I trust this clarifies things <g.

Jamie.

--


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default How to extend a standard class (like Worksheet)

Ok,
I tried to add some property to sheet1 (through Implements
Sheet1 in a class module) but I've been asked to define
everything, even properties as _CodeName, which definition
is an enigma for me. How to do'it? I cannot define a
property with that name in my class module because it
gives me an error (VBA doesn't know how to handle
properties with underscore at the beginning of the prop-
name).

So I'm stuck!

Thanks anyway for help. If you have any other idea please
let me know!

mike

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default How to extend a standard class (like Worksheet)

"mike" wrote ...

Ok,
I tried to add some property to sheet1 (through Implements
Sheet1 in a class module) but I've been asked to define
everything, even properties as _CodeName, which definition
is an enigma for me.


From the help for the Implements statement, "An interface is a
collection of prototypes representing the members (methods and
properties) the interface encapsulates; that is, it contains only the
declarations for the member procedures." Why do you think Sheet1 is a
suitable interface?

Jamie.

--
  #8   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 102
Default How to extend a standard class (like Worksheet)

mike wrote:

Hi to all,

After I tried to implement by myself ... I realize that is
a bit of more complicated so I ask anyone who knows how to
do'it just to tell me:
How can be implemented a subclass of a built-in class like
Worksheet, if it can be? This, in order to add new events,
for example!

Thanks in advance
Mike


Hey, I was going to post exactly the same question here!
I cross-posted to news:microsoft.public.office.developer.vba because
perhaps some of the Word- or Outlook-gurus can help us out here?

--
Amedee Van Gasse using XanaNews 1.16.3.1
If it has an "X" in the name, it must be Linux?
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
how to extend the column limit on a worksheet Jackie Excel Worksheet Functions 1 May 30th 07 04:18 PM
How do you extend the number of blank columns in a worksheet? mybicycleisgreat Excel Worksheet Functions 4 February 5th 06 03:41 PM
DisplayGridlines should be a property of Worksheet class, not Wind Stefano Gatto Excel Discussion (Misc queries) 5 August 25th 05 08:27 AM
I need to do a Worksheet for my Financial Accounting Class. What . vman Excel Worksheet Functions 3 February 18th 05 10:07 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 09:56 PM


All times are GMT +1. The time now is 04:31 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"