Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Need Help With Class Module

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JBNewsGroup - 07 Nov 2004 14:16 GMT
Hi

I have a question regarding Class Modules.

In my UserForm I created a collection of labels as:

   Private colShapeControls AS Collection

                         .....

                         .....

   Set ShapeLabel = fraShapes.Add("Forms.Label.1", "lbl" & ShapeName)

   With ShapeLabel

        .Left = ShapeLeft

        .Top = ShapeTop

        .Height = 20

        .Width = 20

        .Caption = ""

        .Picture = LoadPicture(ShapePath & ShapeName & ".bmp")

        .PicturePosition = fmPicturePositionRightCenter

        .Tag = "lbl" & ShapeName

    End With

   Set cShapeSelect = New clsShapeSelect

   Set cShapeSelect.mShapeSelectNew = ShapeLabel

   colShapeControls.Add cShapeSelect, Cstr(ShapeId)

                         .....

                         .....

The Class Module code is:

  Option Explicit

  Public WithEvents mShapeSelectNew As MSForms.Label

  Private Sub mShapeSelectNew_Click()

       With mShapeSelectNew

             .BackColor = vbYellow

             .SpecialEffect = fmSpecialEffectSunken

       End With

  End Sub

I need help, or a suggestion, of how to determine the previous label
selected.  I am trying to make the labels in the collection mutually
exclusive. If the user selected a label, then selected a different one, I
want to set the previously selected label to its initial state (vbButtonFace
and fmSpecialEffectFlat).

Thanks in advance for any help, and/or suggestions.

Jerry Bodoff
Jonathan West - 07 Nov 2004 21:48 GMT
Hi Jerry

To be able to return the prebious lavel selected, you would do something
like this

above the first routine in the class module, include the following

Private moShapeLast As MSForms.Label
Private moShapeCurrent As MSForms.Label

Then add the following to the

Then, add the following to the Sub mShapeSelectNew_Click routine

Set mShapeLast = mShapeCurrent
Set mShapeCurrent = mShapeSelectNew

Then you can expose the previous label as a property of the classs, like
this

Property Get LastShape() as MSForms.Label
   Set LastShape = mShapeLast
End Property

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi
>
[quoted text clipped - 68 lines]
>
> Jerry Bodoff
Jerry Bodoff - 08 Nov 2004 12:15 GMT
Hi Jonathan,

I tried what you suggested but no cigar. None of the previous information is
saved.  It seems that each time a label is "clicked" a new instance of the
class module is invoked and any information from the previous label is not
retained. It is not "elegant" but is there any way I can interrogate the
Collections array to do what I want or just bite the bullet and code 16
"click" events and a sub?

Previously I asked a similar question and I am using the "container" method
that worked in that project.  However, there I did not have to reset a
previous selection, just insert document text.

As an aside, I am replying via the web.  Is there any parameters that I have
to set up in Outlook Express to not have my text double-space? Since the new
web format I am using Outlook Express as the news reader and everything I
type is double spaced, or more.

I really appreciate your help with this.  Thanks a lot.

Jerry Bodoff

> Hi Jerry
>
[quoted text clipped - 92 lines]
> >
> > Jerry Bodoff
Jonathan West - 08 Nov 2004 14:58 GMT
Rereading your original question again more carefully, it seems that you
want all the labels to be flat except for the currently selected one which
should be yellow & sunken.

If that is the case, then all you need to do on receiving a Click event is
to set *all* the labels to be flat, and then change the settings of just the
selected one.

You can iterate through all the labels in a UserForm like this, before
setting the one you want to be yellow and sunken.

Private Sub mShapeSelectNew_Click()

   Dim oControl as Control
   For Each oControl in mShapeSelectNew.Parent.Controls
       If TypeOf oControl is MSForms.Label Then
           oControl.BackColor = vbButtonFace
           oControl.SpecialEffect = fmSpecialEffectFlat
       End If
   Next oControl
   With mShapeSelectNew
       .BackColor = vbYellow
       .SpecialEffect = fmSpecialEffectSunken
   End With
End Sub

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi Jonathan,
>
[quoted text clipped - 119 lines]
>> >
>> > Jerry Bodoff
Jerry Bodoff - 09 Nov 2004 09:08 GMT
Hi Jonathan,

Fantastic! It works like a charm. I was having trouble because I never used
the "Parent" property before and I did not know how to get to all the labels.
I learned something new.

I will post my Outlook question in the Outlook news group. Using the web and
having to sign in to Passport is a real pain. Besides which, the web page
text is too small. I really liked the old way (I think it was more "user
friendly").

Thanks for all your help. I really appreciated it.

Jerry Bodoff


> Rereading your original question again more carefully, it seems that you
> want all the labels to be flat except for the currently selected one which
[quoted text clipped - 145 lines]
> >> >
> >> > Jerry Bodoff
Jonathan West - 09 Nov 2004 12:58 GMT
> Hi Jonathan,
>
[quoted text clipped - 9 lines]
> text is too small. I really liked the old way (I think it was more "user
> friendly").

Make sure you post to an Outlook Express group rather than an Outlook group.
They are two completely different programs, and Outlook does not do news.

Also, this website may be helpfil to you: http://insideoe.tomsterdam.com/

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

JBNewsGroup - 11 Nov 2004 06:47 GMT
Hi Jonathan,

Last post in this thread.

I finally got Outlook Express fixed, was set for sending HTML and not plain
text.

Regarding sending the clicked label data to the macro.  I created 2 Property
Set's  for setting a pointer to a dummy hidden label on the user form and to
set a pointer to an control which is to receive focus after clicking a
label.  The class module copies the relevant clicked label data to the form
hidden label and then sets focus to the defined control.  It works great.

Thanks for all your help.

Jerry Bodoff

> > Hi Jonathan,
> >
[quoted text clipped - 14 lines]
>
> Also, this website may be helpfil to you: http://insideoe.tomsterdam.com/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.