LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default A class with two objects?

Abe,
If you write a .Delete method in your class.
e.g.
Public Enum DeleteObj
delPic
delCell
delBoth
End Enum

Public Function Delete (DeleteWhat As DeleteObj)
Select Case DeleteWhat
case delPic
mPic.Delete
case delCell
mCell.Delete xlShiftToLeft
case delBoth
mPic.Delete
mCell.Delete xlShiftToLeft
end select
End Function

And then call it from the WS code
cellpic.Delete delPic
'Release the reference
Set cellpic=nothing

It all depends what you want to achieve.

NickHK

wrote in message
oups.com...
That is AWESOME! It will make the coding for my program a lot easier
(and more understandable). Thanks Nick, I am going to go for making the
class (as oppossed to my earlier posted decision). One question, would
.delete work on a cCellPic object, or do I need to define a function in
the class to do that?

-Abe


NickHK wrote:
Abe,
If you are planning on having many of these cell/pic relationships to
together, it would be pretty easy to create a class for this and a
collection of each on a WS to facilitate resyncing (??) or whatever.

e.g.

<cCellPic
Private mCell As Range
Private mPic As Shape

Public Property Set ThisCell(vData As Range)
Set mCell = vData
End Property

Public Property Set ThisPic(vData As Shape)
Set mPic = vData
End Property

Public Property Let CellWidth(vData As Single)
mCell.ColumnWidth = vData
Call ReSync
End Property

Public Function ReSync()
With mCell
mPic.Top = .Top
mPic.Left = .Left
'Need to calculate the scaling correctly
mPic.ScaleWidth .ColumnWidth / mPic.Width, msoTrue,

msoScaleFromTopLeft
mPic.ScaleHeight .RowHeight / mPic.Height, msoFalse,

msoScaleFromTopLeft
End With
End Function
</cCellPic

<WS code
Dim CellPic As cCellPic

Private Sub CommandButton1_Click()
Set CellPic = New Class1

With CellPic
Set .ThisCell = Range("A1")
Set .ThisPic = ActiveSheet.Shapes("Picture 2")
.CellWidth = ActiveSheet.Range("D1").Value
End With

End Sub

NickHK


wrote in message
ups.com...
Yeah, I knew the cell cannot contain a picture, but each picture would
be associated with a cell via position. I now agree with you and have
decided against constructing an object class... Im going about it a
different way. It would have been slick to be able to modify both the
picture and cell from one object though.

Thanks for the response,

-Abe

Leith Ross wrote:
Hello Abraham,

Technically a cell cannot contain a picture. Excel has a separate
drawing layer for pictures and shapes that are placed relative to a
cell's position. You can control the placement of a shape object or
picture on the worksheet using VBA code. There is really no need to
construct your own object class, which would be far more complex to

do.


Sincerely,
Leith Ross


--
Leith Ross

------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=556275




 
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
Implementing Binary Comparisions for a class objects Robert Mulroney[_3_] Excel Programming 7 November 27th 05 10:56 PM
VBA & XL2K: Working with objects/class modules Mike Mertes Excel Programming 0 November 1st 04 02:55 PM
Unable to remove Sheet objects in the Microsoft Excel Objects Adrian[_7_] Excel Programming 1 August 26th 04 10:49 PM
new class w/ graphic objects Tony Rizzo Excel Programming 1 June 7th 04 02:18 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM


All times are GMT +1. The time now is 11:10 AM.

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"